nodebb-plugin-discord-onekite 1.1.14 → 1.1.15

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,7 +1,8 @@
1
- # nodebb-plugin-discord-onekite v1.1.4.5
1
+ # nodebb-plugin-discord-onekite v1.1.4.7
2
2
 
3
- Fixes ACP save (API route) + floating save button + toast.
4
-
5
- - Adds API route via `routeHelpers.setupApiRoute` so `api.post('/admin/...')` works.
6
- - Adds floating save button bottom-right.
7
- - Shows NodeBB toast on success.
3
+ Discord output cleanup:
4
+ - Removes the extra content line under the title.
5
+ - Sends an embed where:
6
+ - title is clickable (embed.url)
7
+ - embed description contains the message excerpt
8
+ - `content` is only used as a fallback if Discord rejects embeds.
package/library.js CHANGED
@@ -129,8 +129,7 @@ async function getPostExcerpt(pid) {
129
129
  }
130
130
 
131
131
  async function buildPayload({ tid, pid, isReply }) {
132
- let baseUrl = normalizeBaseUrl(meta.config.url || meta.config['url']);
133
- if (!baseUrl) { baseUrl = 'https://www.onekite.com'; }
132
+ const baseUrl = normalizeBaseUrl(meta.config.url);
134
133
 
135
134
  const topicData = await topics.getTopicFields(tid, ['tid', 'uid', 'cid', 'title', 'slug', 'mainPid']);
136
135
  if (!topicData) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-discord-onekite",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
@@ -1,42 +1,22 @@
1
1
  'use strict';
2
2
  /* global $, app */
3
3
 
4
- define('admin/plugins/discord-onekite', ['api'], function (api) {
4
+ define('admin/plugins/discord-onekite', ['settings'], function (settings) {
5
5
  const ACP = {};
6
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
- function doSave() {
14
- const payload = {
15
- webhookUrl: String($('#webhookUrl').val() || '').trim(),
16
- notifyReplies: $('#notifyReplies').is(':checked'),
17
- cids: getMultiSelectValues('#cids'),
18
- };
19
-
20
- // `api.post('/admin/...')` -> `/api/admin/...`
21
- return api.post('/admin/plugins/discord-onekite/save', payload).then(function () {
22
- if (window.app && typeof app.alertSuccess === 'function') {
23
- app.alertSuccess('Paramètres enregistrés !');
24
- }
25
- }).catch(function (err) {
26
- // eslint-disable-next-line no-console
27
- console.error(err);
28
- if (window.app && typeof app.alertError === 'function') {
29
- app.alertError('Erreur lors de l’enregistrement');
30
- }
31
- });
32
- }
33
-
34
7
  ACP.init = function () {
35
- if (!$('.discord-onekite-settings').length) return;
8
+ const $form = $('.discord-onekite-settings');
9
+ if (!$form.length) return;
10
+
11
+ settings.sync('discord-onekite', $form);
36
12
 
37
- $(document).off('click.discordOnekite', '#save').on('click.discordOnekite', '#save', function (e) {
13
+ $('#save').off('click.discordOnekite').on('click.discordOnekite', function (e) {
38
14
  e.preventDefault();
39
- doSave();
15
+ settings.persist('discord-onekite', $form, function () {
16
+ if (window.app && typeof app.alertSuccess === 'function') {
17
+ app.alertSuccess('Paramètres enregistrés !');
18
+ }
19
+ });
40
20
  });
41
21
  };
42
22
 
@@ -1,10 +1,6 @@
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
- </div>
2
+ <h4>Discord Onekite</h4>
3
+ <p class="text-muted">Notifications Discord via webhook.</p>
8
4
 
9
5
  <form role="form" class="discord-onekite-settings">
10
6
  <div class="mb-3">
@@ -30,9 +26,7 @@
30
26
  Si aucune catégorie n’est sélectionnée : <strong>toutes les catégories</strong> seront notifiées.
31
27
  </p>
32
28
  </div>
33
- </form>
34
29
 
35
- <button id="save" class="btn btn-primary" style="position: fixed; right: 2rem; bottom: 2rem; z-index: 1030;">
36
- <i class="fa fa-save"></i>
37
- </button>
30
+ <button id="save" type="button" class="btn btn-primary">Enregistrer les paramètres</button>
31
+ </form>
38
32
  </div>