nodebb-plugin-discord-onekite 1.0.12 → 1.0.13

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/README.md CHANGED
@@ -1,5 +1,8 @@
1
- # nodebb-plugin-discord-onekite v1.1.1
1
+ # nodebb-plugin-discord-onekite v1.1.2
2
2
 
3
- Fix:
4
- - Makes embeds ultra-minimal (title/description/url only).
5
- - On Discord 400 embed validation error, retries with plain `content` so a notification is always delivered.
3
+ Fix build error:
4
+ - Removed `acpScripts` and instead provides a proper AMD admin module via `modules` mapping.
5
+ This avoids RequireJS build failures.
6
+
7
+ - Toast "classique NodeBB" via app.alertSuccess when `?saved=1`.
8
+ - Discord notifications: minimal embed + fallback to plain content if Discord rejects embed.
package/library.js CHANGED
@@ -83,8 +83,6 @@ async function sendDiscord(webhookUrl, payload, fallbackContent) {
83
83
  try {
84
84
  await postToDiscord(webhookUrl, payload);
85
85
  } catch (e) {
86
- // Discord embed validation error is commonly 400 with {"embeds":["0"]}
87
- // Retry with plain content so notifications still arrive.
88
86
  if (e && e.statusCode === 400 && fallbackContent) {
89
87
  try {
90
88
  await postToDiscord(webhookUrl, { content: fallbackContent });
@@ -109,11 +107,9 @@ async function buildPayload({ tid, pid, isReply }) {
109
107
  const url = isReply && pid ? `${topicUrl}/${pid}` : topicUrl;
110
108
 
111
109
  const u = await user.getUserFields(topicData.uid, ['username']);
112
-
113
110
  const title = (topicData.title || (isReply ? 'Nouvelle réponse' : 'Nouveau sujet')).toString().slice(0, 256);
114
111
  const authorName = (u && u.username ? String(u.username) : 'Utilisateur').slice(0, 256);
115
112
 
116
- // Super-minimal embed to avoid Discord rejecting unknown/invalid fields.
117
113
  const embed = {
118
114
  title,
119
115
  description: isReply ? `Réponse de **${authorName}**` : `Sujet créé par **${authorName}**`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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
@@ -22,7 +22,7 @@
22
22
  }
23
23
  ],
24
24
  "templates": "templates",
25
- "acpScripts": [
26
- "static/lib/acp-toast.js"
27
- ]
25
+ "modules": {
26
+ "../admin/plugins/discord-onekite.js": "static/lib/admin.js"
27
+ }
28
28
  }
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
- /* global $, app, ajaxify */
2
+ /* global app */
3
3
 
4
- (function () {
5
- function showToastIfSaved() {
6
- if (!ajaxify || !ajaxify.data || ajaxify.data.template !== 'admin/plugins/discord-onekite') return;
4
+ define('admin/plugins/discord-onekite', [], function () {
5
+ const ACP = {};
7
6
 
7
+ function toastIfSaved() {
8
8
  try {
9
9
  const url = new URL(window.location.href);
10
10
  const saved = url.searchParams.get('saved');
@@ -15,9 +15,14 @@
15
15
  url.searchParams.delete('saved');
16
16
  window.history.replaceState({}, document.title, url.toString());
17
17
  }
18
- } catch (e) {}
18
+ } catch (e) {
19
+ // ignore
20
+ }
19
21
  }
20
22
 
21
- $(window).on('action:ajaxify.end', showToastIfSaved);
22
- $(showToastIfSaved);
23
- })();
23
+ ACP.init = function () {
24
+ toastIfSaved();
25
+ };
26
+
27
+ return ACP;
28
+ });
@@ -1,15 +1,9 @@
1
1
  <div class="acp-page-container">
2
2
  <h4>Discord Onekite</h4>
3
3
  <p class="text-muted">
4
- Notifications Discord via webhook (rendu serveur).
4
+ Notifications Discord via webhook.
5
5
  </p>
6
6
 
7
- <!-- IF saved -->
8
- <div class="alert alert-success" role="alert">
9
- Paramètres enregistrés !
10
- </div>
11
- <!-- ENDIF saved -->
12
-
13
7
  <form role="form" method="post" action="/admin/plugins/discord-onekite/save">
14
8
  <input type="hidden" name="_csrf" value="{config.csrf_token}" />
15
9
 
@@ -39,4 +33,10 @@
39
33
 
40
34
  <button type="submit" class="btn btn-primary">Enregistrer</button>
41
35
  </form>
36
+
37
+ <noscript>
38
+ <!-- IF saved -->
39
+ <div class="alert alert-success mt-3" role="alert">Paramètres enregistrés !</div>
40
+ <!-- ENDIF saved -->
41
+ </noscript>
42
42
  </div>