nodebb-plugin-onekite-discord 1.0.17 → 1.0.18

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
@@ -184,6 +184,9 @@ Plugin.addAdminNavigation = (header) => {
184
184
  };
185
185
 
186
186
  Plugin.onTopicPost = async (data) => {
187
+ // Skip scheduled topics — they fire action:topics.scheduled.notify at publish time
188
+ if (data?.topic?.scheduled) return;
189
+
187
190
  const settings = await getSettings();
188
191
  if (!settings.webhookUrl) return;
189
192
 
@@ -197,6 +200,25 @@ Plugin.onTopicPost = async (data) => {
197
200
  await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
198
201
  };
199
202
 
203
+ Plugin.onScheduledTopicsPublish = async (data) => {
204
+ const topicsData = data?.topics;
205
+ if (!Array.isArray(topicsData) || topicsData.length === 0) return;
206
+
207
+ const settings = await getSettings();
208
+ if (!settings.webhookUrl) return;
209
+
210
+ await Promise.all(topicsData.map(async (topic) => {
211
+ const tid = topic?.tid;
212
+ if (!tid) return;
213
+ if (!cidAllowed(topic.cid, settings.cids)) return;
214
+
215
+ const built = await buildEmbed({ tid, isReply: false });
216
+ if (!built) return;
217
+
218
+ await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
219
+ }));
220
+ };
221
+
200
222
  Plugin.onTopicReply = async (data) => {
201
223
  const settings = await getSettings();
202
224
  if (!settings.notifyReplies || !settings.webhookUrl) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-discord",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
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
@@ -18,6 +18,10 @@
18
18
  {
19
19
  "hook": "action:topic.reply",
20
20
  "method": "onTopicReply"
21
+ },
22
+ {
23
+ "hook": "action:topics.scheduled.notify",
24
+ "method": "onScheduledTopicsPublish"
21
25
  }
22
26
  ],
23
27
  "staticDirs": {