question
Is it possible to add custom tags by default when adding a comment to an asset without an extra click by the user? I want to achieve that every comment has some default tags when added in order to display custom moderate queues in the Talk backend.
The queue is working but it's not working properly because the comments do not get the default tags when a user adds a new one.
When comments are added to an asset via the talk embed there will be add other tags to the comment by default.
4.5, Docker
Thanks for help!
🤚 hey @himynameissebbo you should be able to achieve that with the pre hook on the createComment.
example:
https://github.com/coralproject/talk/blob/master/plugins/talk-plugin-akismet/server/hooks.js#L111
i think input. is a good place.
let me know if you'd need anymore help
Hi @hjanuschka, thanks for the quick help. This is exactly what I am looking for!
Maybe you can help with this as well - I have set up the pre hook within my server plugin, but when I add a comment the pre function is not executed. I still got the same output as using the image without the plugin. Plugin is added to the plugin.jsonand building of the docker image with the plugins looks fine.
This is my setup:
/talk-plugin/index.js:
const commentHook = require('./server/commentHook');
module.exports = { commentHook };
/talk-plugin/server/commentHook.js:
module.exports = {
RootMutation: {
createComment: {
pre: async (_, { input }, ctx) => {
console.log('I am executed');
},
},
},
};
Thanks in advance!
try it this way:
index.js
const hooks = require('./server/hooks');
module.exports = { hooks };
server/hooks.js
const debug = require("debug")("my:plugin");
module.exports = {
RootMutation: {
createComment: {
async pre(_, { input }, _context, _info) {
debug("BOOM");
}
}
}
};
Unfortnutatley I still having trouble to see any debug output - this is what my console shows me when adding a new comment with a normal user:
{
"name":"talk",
"version":"4.5.1",
...
"comment_status":"PREMOD",
"msg":"Created comment",
"time":"2018-09-11T08:44:52.956Z",
"src":{
"file":"/usr/src/app/graph/mutators/comment.js",
"line":181,
"func":"createComment"
},
"v":0
}
{
"name":"talk",
"version":"4.5.1",
...
"url":"/api/v1/graph/ql",
"method":"POST",
"statusCode":200,
"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) graphql-ide/1.1.0 Chrome/58.0.3029.110 Electron/1.7.6 Safari/537.36",
"responseTime":20,
"msg":"http request",
"time":"2018-09-11T08:44:52.960Z",
"src":{
"file":"/usr/src/app/middleware/logging.js",
"line":19,
"func":"res.end"
},
"v":0
}
This looks right to me because I have pre-mod activated. But before this one it should call the pre hook, am I right here?
This is the hook:
const debug = require('debug')('talk:plugin:talk-plugin-test');
module.exports = {
RootMutation: {
createComment: {
async pre(_, { input }, _context, _info) {
debug('BOOM');
},
},
},
};
Still trying to figure out why I do not see the "BOOM" here.
Hey @himynameissebbo ,
Have you added your plugin on plugins.json? on server section?
Yap, it's added to the section:
{
"server": [ "talk-plugin-test" ],
}
I checked if the hook is really called once again, and it does. I am able to mutate the incoming comment with a debug body text for example.
I am still wondering why I dont see the debug output then 😑
you should set DEBUG env to the eight level or *
--
Helmut Januschka
Sent with Airmail
Am 11. September 2018 um 11:39:51, Sebastian Mark ([email protected](mailto:[email protected])) schrieb:
I checked if the hook is really called by the app, and it does. I am able to mutate the incoming comment with a debug body text for example.
I am still wondering why I dont see the debug output then 😑
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub(https://github.com/coralproject/talk/issues/1859#issuecomment-420212189), or mute the thread(https://github.com/notifications/unsubscribe-auth/ACwftosJQdFxYVCemUG22EajEg2etx_Hks5uZ4TmgaJpZM4Wh4Ye).
It works! Big s/o to you @hjanuschka!
Have a nice day!
Most helpful comment
🤚 hey @himynameissebbo you should be able to achieve that with the
prehook on thecreateComment.example:
https://github.com/coralproject/talk/blob/master/plugins/talk-plugin-akismet/server/hooks.js#L111
i think
input.is a good place.let me know if you'd need anymore help