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 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
- return { topicData, embed: { title: safeTitle, url: targetUrl, description: excerpt || '' } };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-discord",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -32,5 +32,5 @@
32
32
  "acpScripts": [
33
33
  "public/admin.js"
34
34
  ],
35
- "version": "1.1.4.19"
35
+ "version": "1.0.2"
36
36
  }