nodebb-plugin-discord-onekite 1.1.8 → 1.1.9

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,5 @@
1
- # nodebb-plugin-discord-onekite v1.1.7
1
+ # nodebb-plugin-discord-onekite v1.1.8
2
2
 
3
- Fixes webpack template build errors by removing `<!-- IMPORT admin/partials/save_button.tpl -->` and using an inline save button.
4
-
5
- Everything else unchanged from v1.1.6.
3
+ This variant avoids RequireJS admin modules (no `modules` / no AMD) to prevent requirejs build failures.
4
+ ACP saves with a normal POST + redirect and shows a success banner.
5
+ Discord notifications unchanged.
@@ -40,6 +40,7 @@ controllers.renderAdminPage = async function (req, res) {
40
40
  res.render('admin/plugins/discord-onekite', {
41
41
  settings: settings || {},
42
42
  categories: categoriesForTpl,
43
+ saved: req.query && (req.query.saved === '1' || req.query.saved === 'true'),
43
44
  });
44
45
  };
45
46
 
package/library.js CHANGED
@@ -94,7 +94,6 @@ async function sendDiscord(webhookUrl, payload) {
94
94
  try {
95
95
  await postToDiscord(webhookUrl, payload);
96
96
  } catch (e) {
97
- // If Discord rejects embeds, retry with plain content only.
98
97
  if (e && e.statusCode === 400 && payload && payload.content) {
99
98
  try {
100
99
  await postToDiscord(webhookUrl, { content: payload.content });
@@ -130,14 +129,13 @@ async function buildPayload({ tid, pid, isReply }) {
130
129
  const title = (topicData.title || (isReply ? 'Nouvelle réponse' : 'Nouveau sujet')).toString().slice(0, 256);
131
130
  const excerpt = await getPostExcerpt(isReply ? pid : topicData.mainPid);
132
131
 
133
- // Single clickable link line + excerpt below
134
132
  const linkLine = isReply
135
133
  ? `🗨️ Nouvelle réponse : [${title}](${targetUrl})`
136
134
  : `🆕 Nouveau sujet : [${title}](${topicUrl})`;
137
135
 
138
136
  const content = [linkLine, excerpt].filter(Boolean).join('\n');
139
137
 
140
- const embed = { title, description: excerpt || '' , url: targetUrl };
138
+ const embed = { title, description: excerpt || '', url: targetUrl };
141
139
 
142
140
  return { topicData, content, embed };
143
141
  }
@@ -158,7 +156,6 @@ Plugin.init = async ({ router }) => {
158
156
  controllers.renderAdminPage
159
157
  );
160
158
 
161
- // AJAX save endpoint (used by admin.js via api.post)
162
159
  router.post('/admin/plugins/discord-onekite/save',
163
160
  middleware.admin.checkPrivileges,
164
161
  async (req, res) => {
@@ -169,11 +166,10 @@ Plugin.init = async ({ router }) => {
169
166
  cids: req.body.cids || '',
170
167
  };
171
168
  await meta.settings.set(SETTINGS_KEY, payload);
172
- res.json({ ok: true });
173
169
  } catch (e) {
174
170
  console.error('[discord-onekite] save failed', e);
175
- res.status(500).json({ ok: false });
176
171
  }
172
+ res.redirect('/admin/plugins/discord-onekite?saved=1');
177
173
  }
178
174
  );
179
175
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
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
@@ -21,8 +21,5 @@
21
21
  "method": "onTopicReply"
22
22
  }
23
23
  ],
24
- "templates": "templates",
25
- "modules": {
26
- "../admin/plugins/discord-onekite.js": "static/lib/admin.js"
27
- }
24
+ "templates": "templates"
28
25
  }
@@ -1,15 +1,14 @@
1
1
  <div class="acp-page-container">
2
- <div class="d-flex justify-content-between align-items-start mb-3">
3
- <div>
4
- <h4 class="mb-1">Discord Onekite</h4>
5
- <p class="text-muted mb-0">Notifications Discord via webhook.</p>
6
- </div>
7
- <button id="save" class="btn btn-primary">
8
- <i class="fa fa-save"></i> Enregistrer
9
- </button>
10
- </div>
2
+ <h4>Discord Onekite</h4>
3
+ <p class="text-muted">Notifications Discord via webhook.</p>
4
+
5
+ <!-- IF saved -->
6
+ <div class="alert alert-success" role="alert">Paramètres enregistrés !</div>
7
+ <!-- ENDIF saved -->
8
+
9
+ <form role="form" method="post" action="/admin/plugins/discord-onekite/save">
10
+ <input type="hidden" name="_csrf" value="{config.csrf_token}" />
11
11
 
12
- <form role="form" class="discord-onekite-settings">
13
12
  <div class="mb-3">
14
13
  <label class="form-label" for="webhookUrl">Discord Webhook URL</label>
15
14
  <input type="text" class="form-control" id="webhookUrl" name="webhookUrl" value="{settings.webhookUrl}" placeholder="https://discord.com/api/webhooks/..." />
@@ -33,5 +32,7 @@
33
32
  Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
34
33
  </p>
35
34
  </div>
35
+
36
+ <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Enregistrer</button>
36
37
  </form>
37
38
  </div>
@@ -1,40 +0,0 @@
1
- 'use strict';
2
- /* global $, app */
3
-
4
- define('admin/plugins/discord-onekite', ['api'], function (api) {
5
- const ACP = {};
6
-
7
- function getMultiSelectValues(selector) {
8
- const el = document.querySelector(selector);
9
- if (!el) return [];
10
- return Array.from(el.selectedOptions || []).map(o => o.value);
11
- }
12
-
13
- ACP.init = function () {
14
- const $form = $('.discord-onekite-settings');
15
- if (!$form.length) return;
16
-
17
- $('#save').off('click.discordOnekite').on('click.discordOnekite', function () {
18
- const payload = {
19
- webhookUrl: String($('#webhookUrl').val() || '').trim(),
20
- notifyReplies: $('#notifyReplies').is(':checked'),
21
- cids: getMultiSelectValues('#cids'),
22
- };
23
-
24
- // api.post prefixes /api automatically, so server route must be /admin/...
25
- api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
26
- if (window.app && typeof app.alertSuccess === 'function') {
27
- app.alertSuccess('Paramètres enregistrés !');
28
- }
29
- }).catch(function (err) {
30
- // eslint-disable-next-line no-console
31
- console.error(err);
32
- if (window.app && typeof app.alertError === 'function') {
33
- app.alertError('Erreur lors de l’enregistrement');
34
- }
35
- });
36
- });
37
- };
38
-
39
- return ACP;
40
- });