Skip to content

Commit 8ce2a32

Browse files
committed
feat: dont call openai if chatgpt user doesnt have reply privilege in topic
1 parent 6fdd46c commit 8ce2a32

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const topics = require.main.require('./src/topics');
1313
const user = require.main.require('./src/user');
1414
const messaging = require.main.require('./src/messaging');
1515
const api = require.main.require('./src/api');
16+
const privileges = require.main.require('./src/privileges');
1617

1718
const plugin = module.exports;
1819

@@ -42,6 +43,10 @@ plugin.actionMentionsNotify = async function (hookData) {
4243
return;
4344
}
4445
if (notification.tid && notification.bodyLong.startsWith(`@${chatgptusername}`)) {
46+
const canReply = await privileges.topics.can('topics:reply', notification.tid, chatgptUid);
47+
if (!canReply) {
48+
return;
49+
}
4550
const message = notification.bodyLong.replace(new RegExp(`^@${chatgptusername}`), '');
4651
if (message.length) {
4752
const response = await chatComplete(message);

0 commit comments

Comments
 (0)