nodebb-plugin-composer-default 10.2.14 → 10.2.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/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"composer/tags.js": "./static/lib/composer/tags.js",
|
|
29
29
|
"composer/uploads.js": "./static/lib/composer/uploads.js",
|
|
30
30
|
"composer/autocomplete.js": "./static/lib/composer/autocomplete.js",
|
|
31
|
+
"composer/post-queue.js": "./static/lib/composer/post-queue.js",
|
|
31
32
|
"../admin/plugins/composer-default.js": "./static/lib/admin.js"
|
|
32
33
|
},
|
|
33
34
|
"templates": "static/templates"
|
|
@@ -97,9 +97,10 @@ define('composer/categoryList', [
|
|
|
97
97
|
const categoryData = await window.fetch(`${config.relative_path}/api/category/${selectedCategory.cid}`).then(r => r.json());
|
|
98
98
|
postData.category = categoryData;
|
|
99
99
|
updateTaskbarByCategory(postContainer, categoryData);
|
|
100
|
-
require(['composer/scheduler', 'composer/tags'], function (scheduler, tags) {
|
|
100
|
+
require(['composer/scheduler', 'composer/tags', 'composer/post-queue'], function (scheduler, tags, postQueue) {
|
|
101
101
|
scheduler.onChangeCategory(categoryData);
|
|
102
102
|
tags.onChangeCategory(postContainer, postData, selectedCategory.cid, categoryData);
|
|
103
|
+
postQueue.onChangeCategory(postContainer, postData);
|
|
103
104
|
|
|
104
105
|
$(window).trigger('action:composer.changeCategory', {
|
|
105
106
|
postContainer: postContainer,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
define('composer/post-queue', [], function () {
|
|
4
|
+
const postQueue = {};
|
|
5
|
+
|
|
6
|
+
postQueue.isExempt = async function (postData) {
|
|
7
|
+
if (!config.postQueue || app.user.isAdmin || app.user.isGlobalMod || app.user.isMod) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return await socket.emit('plugins.composer.isExemptFromPostQueue', { postData: postData });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
postQueue.onChangeCategory = async function (postContainer, postData) {
|
|
14
|
+
if (!config.postQueue) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const isExempt = await postQueue.isExempt(postData);
|
|
18
|
+
postContainer.find('[component="composer/post-queue/alert"]')
|
|
19
|
+
.toggleClass('hidden', isExempt);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return postQueue;
|
|
23
|
+
});
|
package/static/lib/composer.js
CHANGED
|
@@ -12,6 +12,7 @@ define('composer', [
|
|
|
12
12
|
'composer/resize',
|
|
13
13
|
'composer/autocomplete',
|
|
14
14
|
'composer/scheduler',
|
|
15
|
+
'composer/post-queue',
|
|
15
16
|
'scrollStop',
|
|
16
17
|
'topicThumbs',
|
|
17
18
|
'api',
|
|
@@ -22,7 +23,7 @@ define('composer', [
|
|
|
22
23
|
'search',
|
|
23
24
|
'screenfull',
|
|
24
25
|
], function (taskbar, translator, uploads, formatting, drafts, tags,
|
|
25
|
-
categoryList, preview, resize, autocomplete, scheduler, scrollStop,
|
|
26
|
+
categoryList, preview, resize, autocomplete, scheduler, postQueue, scrollStop,
|
|
26
27
|
topicThumbs, api, bootbox, alerts, hooks, messagesModule, search, screenfull) {
|
|
27
28
|
var composer = {
|
|
28
29
|
active: undefined,
|
|
@@ -476,6 +477,7 @@ define('composer', [
|
|
|
476
477
|
tagWhitelist: postData.category ? postData.category.tagWhitelist : ajaxify.data.tagWhitelist,
|
|
477
478
|
privileges: app.user.privileges,
|
|
478
479
|
selectedCategory: postData.category,
|
|
480
|
+
exemptFromPostQueue: await postQueue.isExempt(postData),
|
|
479
481
|
submitOptions: [
|
|
480
482
|
// Add items using `filter:composer.create`, or just add them to the <ul> in DOM
|
|
481
483
|
// {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<div class="write-preview-container d-flex gap-2 flex-grow-1 overflow-auto">
|
|
2
|
-
<div class="write-container d-flex d-md-flex w-50">
|
|
2
|
+
<div class="write-container d-flex d-md-flex w-50 position-relative">
|
|
3
|
+
<div component="composer/post-queue/alert" class="{{{ if exemptFromPostQueue }}}hidden{{{ end }}} m-2 alert alert-info position-absolute top-0 start-0 alert-dismissible">[[modules:composer.post-queue-alert]]<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>
|
|
3
4
|
<div class="float-end draft-icon hidden-md hidden-lg"></div>
|
|
4
5
|
<textarea class="write shadow-none rounded-1 w-100 form-control" tabindex="4" placeholder="[[modules:composer.textarea.placeholder]]">{body}</textarea>
|
|
5
6
|
</div>
|
package/websockets.js
CHANGED
|
@@ -66,5 +66,29 @@ Sockets.renderHelp = async function () {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
Sockets.getFormattingOptions = async function () {
|
|
69
|
-
return await
|
|
69
|
+
return await require('./library').getFormattingOptions();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Sockets.isExemptFromPostQueue = async function (socket, data) {
|
|
73
|
+
if (!data || !data.postData) {
|
|
74
|
+
throw new Error('[[error:invalid-data]]');
|
|
75
|
+
}
|
|
76
|
+
if (socket.uid <= 0) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let shouldQueue = false;
|
|
81
|
+
const { postData } = data;
|
|
82
|
+
if (postData.action === 'posts.reply') {
|
|
83
|
+
shouldQueue = await posts.shouldQueue(socket.uid, {
|
|
84
|
+
tid: postData.tid,
|
|
85
|
+
content: postData.content || '',
|
|
86
|
+
});
|
|
87
|
+
} else if (postData.action === 'topics.post') {
|
|
88
|
+
shouldQueue = await posts.shouldQueue(socket.uid, {
|
|
89
|
+
cid: postData.cid,
|
|
90
|
+
content: postData.content || '',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return !shouldQueue;
|
|
70
94
|
};
|