Skip to content

Commit

Permalink
Merge pull request #4045 from thematters/release/v5.1.0
Browse files Browse the repository at this point in the history
Release: v5.1.0
  • Loading branch information
gary02 committed Jul 10, 2024
2 parents 034d62b + dc34a0a commit 049e901
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matters-server",
"version": "5.0.5",
"version": "5.1.0",
"description": "Matters Server",
"author": "Matters <hi@matters.news>",
"main": "build/index.js",
Expand Down
21 changes: 19 additions & 2 deletions src/mutations/comment/voteComment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import type { GQLMutationResolvers, Article, Circle } from 'definitions'

import { COMMENT_TYPE, USER_STATE } from 'common/enums'
import { COMMENT_TYPE, USER_STATE, VOTE, DB_NOTICE_TYPE } from 'common/enums'
import { ForbiddenByStateError, ForbiddenError } from 'common/errors'
import { fromGlobalId } from 'common/utils'

const resolver: GQLMutationResolvers['voteComment'] = async (
_,
{ input: { id, vote } },
{ viewer, dataSources: { atomService, paymentService, commentService } }
{
viewer,
dataSources: {
atomService,
paymentService,
commentService,
notificationService,
},
}
) => {
if (!viewer.userName) {
throw new ForbiddenError('user has no username')
Expand Down Expand Up @@ -65,6 +73,15 @@ const resolver: GQLMutationResolvers['voteComment'] = async (

await commentService.vote({ commentId: dbId, vote, userId: viewer.id })

if (vote === VOTE.up) {
notificationService.trigger({
event: DB_NOTICE_TYPE.comment_liked,
actorId: viewer.id,
recipientId: comment.authorId,
entities: [{ type: 'target', entityTable: 'comment', entity: comment }],
})
}

return comment
}

Expand Down

0 comments on commit 049e901

Please sign in to comment.