nodebb-plugin-onekite-discord 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/library.js +10 -3
- package/package.json +1 -1
- package/plugin.json +1 -1
package/library.js
CHANGED
|
@@ -8,6 +8,7 @@ const meta = require.main.require('./src/meta');
|
|
|
8
8
|
const topics = require.main.require('./src/topics');
|
|
9
9
|
const categories = require.main.require('./src/categories');
|
|
10
10
|
const posts = require.main.require('./src/posts');
|
|
11
|
+
const user = require.main.require('./src/user');
|
|
11
12
|
|
|
12
13
|
const controllers = require('./lib/controllers');
|
|
13
14
|
const adminApi = require('./lib/admin');
|
|
@@ -170,7 +171,13 @@ async function buildEmbed({ tid, pid, isReply }) {
|
|
|
170
171
|
|
|
171
172
|
const excerpt = await getPostExcerpt(isReply ? pid : topicData.mainPid);
|
|
172
173
|
|
|
173
|
-
|
|
174
|
+
const postForUser = await posts.getPostFields(isReply ? pid : topicData.mainPid, ['uid']);
|
|
175
|
+
const username = await user.getUserField(postForUser.uid, 'username');
|
|
176
|
+
|
|
177
|
+
// "Titre actuel avec lien" - Pseudo (pseudo sans lien)
|
|
178
|
+
const content = `[${safeTitle}](${targetUrl}) - ${username}`;
|
|
179
|
+
|
|
180
|
+
return { topicData, content, embed: { description: excerpt || '' } };
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
function extractTidPid(data) {
|
|
@@ -215,7 +222,7 @@ Plugin.onTopicPost = async (data) => {
|
|
|
215
222
|
if (!built) return;
|
|
216
223
|
if (!cidAllowed(built.topicData.cid, settings.cids)) return;
|
|
217
224
|
|
|
218
|
-
await sendDiscord(settings.webhookUrl, { embeds: [built.embed] });
|
|
225
|
+
await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
|
|
219
226
|
};
|
|
220
227
|
|
|
221
228
|
Plugin.onTopicReply = async (data) => {
|
|
@@ -230,7 +237,7 @@ Plugin.onTopicReply = async (data) => {
|
|
|
230
237
|
if (!built) return;
|
|
231
238
|
if (!cidAllowed(built.topicData.cid, settings.cids)) return;
|
|
232
239
|
|
|
233
|
-
await sendDiscord(settings.webhookUrl, { embeds: [built.embed] });
|
|
240
|
+
await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
|
|
234
241
|
};
|
|
235
242
|
|
|
236
243
|
module.exports = Plugin;
|
package/package.json
CHANGED
package/plugin.json
CHANGED