Skip to content

Commit

Permalink
feat(notice): remove comment_pinned notice
Browse files Browse the repository at this point in the history
as article author can only pin their own comments now

resolve #3950
  • Loading branch information
gary02 committed Jun 21, 2024
1 parent 05671f4 commit 0cac123
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 40 deletions.
1 change: 0 additions & 1 deletion src/common/enums/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export enum DB_NOTICE_TYPE {
article_new_collected = 'article_new_collected',

// comment
comment_pinned = 'comment_pinned',
comment_mentioned_you = 'comment_mentioned_you',
article_new_comment = 'article_new_comment',
circle_new_broadcast = 'circle_new_broadcast',
Expand Down
1 change: 0 additions & 1 deletion src/connectors/__test__/notificationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('user notify setting', () => {
article_new_collected: false,

// comment
comment_pinned: false,
comment_mentioned_you: true,
article_new_comment: true,
circle_new_broadcast: true,
Expand Down
1 change: 0 additions & 1 deletion src/connectors/notificationService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export class NotificationService {
case DB_NOTICE_TYPE.article_new_subscriber:
case DB_NOTICE_TYPE.article_mentioned_you:
case DB_NOTICE_TYPE.comment_mentioned_you:
case DB_NOTICE_TYPE.comment_pinned:
case DB_NOTICE_TYPE.article_new_comment:
case DB_NOTICE_TYPE.comment_new_reply:
case DB_NOTICE_TYPE.payment_received_donation:
Expand Down
25 changes: 0 additions & 25 deletions src/connectors/notificationService/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,30 +385,6 @@ export class Notice extends BaseService<NoticeDB> {
return actors
}

/**
* Find notices by given ids.
*/
private findByIds = async (ids: readonly string[]): Promise<NoticeItem[]> => {
const notices = await this.findDetail({
whereIn: ['notice.id', ids as string[]],
})

return Promise.all(
notices.map(async (n: NoticeDetail) => {
const entities = (await this.findEntities(n.id)) as NoticeEntitiesMap
const actors = await this.findActors(n.id)

return {
...n,
createdAt: n.updatedAt,
type: n.noticeType,
actors,
entities,
}
})
)
}

/*********************************
* *
* By User *
Expand Down Expand Up @@ -480,7 +456,6 @@ export class Notice extends BaseService<NoticeDB> {
article_new_collected: setting.articleNewCollected,

// comment
comment_pinned: setting.articleCommentPinned,
comment_mentioned_you: setting.mention,
article_new_comment: setting.articleNewComment,
circle_new_broadcast: setting.inCircleNewBroadcast,
Expand Down
10 changes: 1 addition & 9 deletions src/mutations/comment/togglePinComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { GQLMutationResolvers, Article, Circle } from 'definitions'
import {
CACHE_KEYWORD,
COMMENT_TYPE,
DB_NOTICE_TYPE,
NODE_TYPES,
} from 'common/enums'
import {
Expand All @@ -19,7 +18,7 @@ const resolver: Exclude<
> = async (
_,
{ input: { id, enabled } },
{ viewer, dataSources: { atomService, commentService, notificationService } }
{ viewer, dataSources: { atomService, commentService } }
) => {
if (!viewer.id) {
throw new AuthenticationError('visitor has no permission')
Expand Down Expand Up @@ -97,13 +96,6 @@ const resolver: Exclude<
},
})

// trigger notifications
notificationService.trigger({
event: DB_NOTICE_TYPE.comment_pinned,
actorId: viewer.id,
recipientId: comment.authorId,
entities: [{ type: 'target', entityTable: 'comment', entity: comment }],
})
} else {
pinnedComment = await atomService.update({
table: 'comment',
Expand Down
3 changes: 0 additions & 3 deletions src/queries/notice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ const notice: {
CommentNotice: {
type: ({ type }) => {
switch (type) {
case DB_NOTICE_TYPE.comment_pinned:
return 'CommentPinned'
case DB_NOTICE_TYPE.comment_mentioned_you:
return 'CommentMentionedYou'
case DB_NOTICE_TYPE.article_new_comment:
Expand All @@ -173,7 +171,6 @@ const notice: {
throw new ServerError('entities is empty')
}
switch (type) {
case DB_NOTICE_TYPE.comment_pinned:
case DB_NOTICE_TYPE.comment_mentioned_you:
case DB_NOTICE_TYPE.circle_new_broadcast: // deprecated
return entities.target
Expand Down

0 comments on commit 0cac123

Please sign in to comment.