Hide non-published posts from post count.
Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>feature/profile
parent
efa5eaedcc
commit
f400bbe251
|
@ -160,14 +160,14 @@ async function newPost({ requester_id }) {
|
||||||
|
|
||||||
return post.id;
|
return post.id;
|
||||||
}
|
}
|
||||||
async function getPost({ requester_id, post_id, visibility = "PUBLISHED" } = {}, { search, search_title, search_content, search_tags } = {}, { limit = 10, page = 0, pagination = true } = {}) {
|
async function getPost({ requester_id, owner_id, post_id, visibility = "PUBLISHED" } = {}, { search, search_title, search_content, search_tags } = {}, { limit = 10, page = 0, pagination = true } = {}) {
|
||||||
let where_object = {
|
let where_object = {
|
||||||
OR: [
|
OR: [
|
||||||
// Standard discovery: Public, and after the publish date
|
// Standard discovery: Public, and after the publish date
|
||||||
{
|
{
|
||||||
AND: [
|
AND: [
|
||||||
{
|
{
|
||||||
visibility: "PUBLISHED",
|
visibility: visibility,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
publish_date: {
|
publish_date: {
|
||||||
|
@ -230,6 +230,10 @@ async function getPost({ requester_id, post_id, visibility = "PUBLISHED" } = {},
|
||||||
let post_list = [];
|
let post_list = [];
|
||||||
|
|
||||||
// Build the "where_object" object
|
// Build the "where_object" object
|
||||||
|
if (owner_id) {
|
||||||
|
where_object["AND"].push({ owner: { id: owner_id } });
|
||||||
|
}
|
||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
if (search_tags) where_object["AND"][0]["OR"].push({ tags: { some: { name: search?.toLowerCase() } } });
|
if (search_tags) where_object["AND"][0]["OR"].push({ tags: { some: { name: search?.toLowerCase() } } });
|
||||||
if (search_title) where_object["AND"][0]["OR"].push({ title: { contains: search, mode: "insensitive" } });
|
if (search_title) where_object["AND"][0]["OR"].push({ title: { contains: search, mode: "insensitive" } });
|
||||||
|
|
|
@ -51,7 +51,7 @@ async function author(req, res) {
|
||||||
user = user.data;
|
user = user.data;
|
||||||
const profile = await core.getBiography({ author_id: user.id });
|
const profile = await core.getBiography({ author_id: user.id });
|
||||||
// TODO: Check for success
|
// TODO: Check for success
|
||||||
const posts = await core.getPost({ requester_id: user.id });
|
const posts = await core.getPost({ owner_id: user.id, visibility: "PUBLISHED" });
|
||||||
const profile_image = await core.getMedia({ parent_id: user.id, parent_type: "user", file_name: user.profile_image });
|
const profile_image = await core.getMedia({ parent_id: user.id, parent_type: "user", file_name: user.profile_image });
|
||||||
|
|
||||||
res.render(_getThemePage("author"), { ...(await getDefaults(req)), post: { ...profile.data, post_count: posts.data.length, profile_image: profile_image } });
|
res.render(_getThemePage("author"), { ...(await getDefaults(req)), post: { ...profile.data, post_count: posts.data.length, profile_image: profile_image } });
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global qs request */
|
||||||
|
|
||||||
async function changeValue(setting_name, value) {
|
async function changeValue(setting_name, value) {
|
||||||
const form = {
|
const form = {
|
||||||
setting_name: setting_name,
|
setting_name: setting_name,
|
||||||
|
|
Loading…
Reference in New Issue