Skip to content

Commit

Permalink
Fix manually published scheduled posts (#146)
Browse files Browse the repository at this point in the history
* Update createdAt date on manual publish of scheduled post

* Publish notification when manually publishing scheduled post
  • Loading branch information
Oscariremma authored Dec 8, 2024
1 parent 4d35a0a commit 16c2546
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/services/newsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default class NewsService {
const publish =
edited.scheduledPublish === null && post?.status === PostStatus.SCHEDULED;

return await prisma.newsPost.update({
const updatedPost = await prisma.newsPost.update({
where: {
id: edited.id
},
Expand All @@ -181,11 +181,16 @@ export default class NewsService {
contentEn: edited.contentEn,
contentSv: edited.contentSv,
status: publish ? PostStatus.PUBLISHED : undefined,
createdAt: publish ? new Date() : undefined,
scheduledPublish: updateScheduledPublish
? edited.scheduledPublish
: undefined
}
});

if (publish) NotifyService.notifyNewsPost(updatedPost);

return updatedPost;
}

static async remove(id: number) {
Expand Down

0 comments on commit 16c2546

Please sign in to comment.