Skip to content

Commit

Permalink
omg...
Browse files Browse the repository at this point in the history
  • Loading branch information
bandinopla committed Mar 29, 2024
1 parent 696d9e9 commit 625220b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions server/db/resolvers/forum/forum-announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export async function getAnnouncementsCount() {
return total?.[0].totalCount ?? 0;
}

export async function getAnnouncementsThreadMessages ( forumThreadRow, limit, pushThreadHere )
export async function getAnnouncementsThreadMessages ( args, limit, pushThreadHere, $pointerId )
{
const globalId = forumThreadRow.post_comment.replace("global:", "");
const globalId = $pointerId.replace("global:", "");
const global = await query(`SELECT * FROM messages WHERE id=?`, [ globalId ]);

if(!global.length)
Expand All @@ -65,11 +65,11 @@ export async function getAnnouncementsThreadMessages ( forumThreadRow, limit, pu
post_preview:""
}

const proxy = await query(`SELECT * FROM forum WHERE post_comment=?`, [ args.messageId ]);
const proxy = await query(`SELECT * FROM forum WHERE post_comment=?`, [ $pointerId ]);

if(!proxy.length)
{
const created = await query( `INSERT INTO forum SET ?`, { ...thread, post_comment: args.messageId } );
const created = await query( `INSERT INTO forum SET ?`, { ...thread, post_comment: $pointerId } );

if(!created.insertId )
{
Expand Down
13 changes: 9 additions & 4 deletions server/db/resolvers/forum/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,20 @@ export const ForumResolver = {
let messages ;

let thread = await query(`SELECT * FROM forum WHERE id=?`, [ args.messageId ]);
let idForSection ;
let sectionHook = SECTIONS.find( s=> {
idForSection = s.idIsMine?
s.idIsMine(args.messageId) ? args.messageId :
s.idIsMine(thread[0]?.post_comment) ? thread[0]?.post_comment : null
: null;

let sectionHook = SECTIONS.find( s=> s.idIsMine && (s.idIsMine(args.messageId) || s.idIsMine(thread[0]?.post_comment)) );
return idForSection? s : null;
});

if( sectionHook )
{
let threadRow = thread[0];

thread = [];
messages = await sectionHook.getThreadMessages()( threadRow, limit, thread );
messages = await sectionHook.getThreadMessages()( args, limit, thread, idForSection );
}
else
{
Expand Down

0 comments on commit 625220b

Please sign in to comment.