mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
Handle comment flags
This commit is contained in:
+18
-1
@@ -12,7 +12,9 @@ const {deserializeUser} = require('../services/subscriptions');
|
||||
|
||||
const {
|
||||
SUBSCRIBE_COMMENT_STATUS,
|
||||
SUBSCRIBE_COMMENT_FLAGS,
|
||||
SUBSCRIBE_ALL_COMMENT_EDITS,
|
||||
SUBSCRIBE_ALL_COMMENT_ADDITIONS,
|
||||
} = require('../perms/constants');
|
||||
|
||||
/**
|
||||
@@ -27,7 +29,12 @@ const setupFunctions = plugins.get('server', 'setupFunctions').reduce((acc, {plu
|
||||
}, {
|
||||
commentAdded: (options, args) => ({
|
||||
commentAdded: {
|
||||
filter: (comment) => comment.asset_id === args.asset_id
|
||||
filter: (comment, context) => {
|
||||
if (!args.asset_id && (!context.user || !context.user.can(SUBSCRIBE_ALL_COMMENT_ADDITIONS))) {
|
||||
return false;
|
||||
}
|
||||
return !args.asset_id || comment.asset_id === args.asset_id;
|
||||
}
|
||||
},
|
||||
}),
|
||||
commentEdited: (options, args) => ({
|
||||
@@ -40,6 +47,16 @@ const setupFunctions = plugins.get('server', 'setupFunctions').reduce((acc, {plu
|
||||
}
|
||||
},
|
||||
}),
|
||||
commentFlagged: (options, args) => ({
|
||||
commentFlagged: {
|
||||
filter: ({comment}, context) => {
|
||||
if (!context.user || !context.user.can(SUBSCRIBE_COMMENT_FLAGS)) {
|
||||
return false;
|
||||
}
|
||||
return !args.asset_id || comment.asset_id === args.asset_id;
|
||||
}
|
||||
},
|
||||
}),
|
||||
commentStatusChanged: (options, args) => ({
|
||||
commentStatusChanged: {
|
||||
filter: ({comment}, context) => {
|
||||
|
||||
Reference in New Issue
Block a user