nodebb-plugin-mentions 4.7.0 → 4.7.1
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/.eslintrc +2 -2
- package/LICENSE +7 -7
- package/README.md +13 -13
- package/library.js +8 -11
- package/package.json +1 -1
- package/static/.eslintrc +3 -3
package/.eslintrc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "nodebb/lib"
|
|
1
|
+
{
|
|
2
|
+
"extends": "nodebb/lib"
|
|
3
3
|
}
|
package/LICENSE
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Copyright (c) 2013-2014, Julian Lam <julian@designcreateplay.com>
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
1
|
+
Copyright (c) 2013-2014, Julian Lam <julian@designcreateplay.com>
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
8
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Username/Group Mentions
|
|
2
|
-
|
|
3
|
-
This NodeBB plugin allows posters to reference (or *mention*) other users or groups on a NodeBB by simply
|
|
4
|
-
precluding the `@` symbol before a username.
|
|
5
|
-
|
|
6
|
-
A link is automatically added to the post.
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
This plugin is bundled with every NodeBB install. If not, you can install it via the Plugins page of the ACP.
|
|
11
|
-
|
|
12
|
-
Alternatively,
|
|
13
|
-
|
|
1
|
+
# Username/Group Mentions
|
|
2
|
+
|
|
3
|
+
This NodeBB plugin allows posters to reference (or *mention*) other users or groups on a NodeBB by simply
|
|
4
|
+
precluding the `@` symbol before a username.
|
|
5
|
+
|
|
6
|
+
A link is automatically added to the post.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
This plugin is bundled with every NodeBB install. If not, you can install it via the Plugins page of the ACP.
|
|
11
|
+
|
|
12
|
+
Alternatively,
|
|
13
|
+
|
|
14
14
|
npm install nodebb-plugin-mentions
|
package/library.js
CHANGED
|
@@ -81,7 +81,7 @@ function getNoMentionGroups() {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
Mentions.notify = async function ({ post }) {
|
|
84
|
-
const postOwner =
|
|
84
|
+
const postOwner = String(post.uid);
|
|
85
85
|
|
|
86
86
|
let uidsToNotify;
|
|
87
87
|
let groupsToNotify;
|
|
@@ -109,9 +109,9 @@ Mentions.notify = async function ({ post }) {
|
|
|
109
109
|
} else if (post._activitypub) { // ActivityPub
|
|
110
110
|
const { tag } = post._activitypub;
|
|
111
111
|
groupsToNotify = []; // cannot mention groups for now
|
|
112
|
-
|
|
112
|
+
let slugs = [];
|
|
113
113
|
if (Array.isArray(tag) && tag.length) {
|
|
114
|
-
|
|
114
|
+
slugs = tag.reduce((slugs, tag) => {
|
|
115
115
|
if (tag.type === 'Mention' && tag.name && typeof tag.name === 'string') {
|
|
116
116
|
const [slug, hostname] = tag.name.slice(1).split('@');
|
|
117
117
|
if (hostname === nconf.get('url_parsed').hostname) {
|
|
@@ -120,18 +120,16 @@ Mentions.notify = async function ({ post }) {
|
|
|
120
120
|
}
|
|
121
121
|
return slugs;
|
|
122
122
|
}, []);
|
|
123
|
-
|
|
124
|
-
uidsToNotify = slugs.length ? await db.sortedSetScores('userslug:uid', slugs) : [];
|
|
125
|
-
} else {
|
|
126
|
-
uidsToNotify = [];
|
|
127
123
|
}
|
|
124
|
+
uidsToNotify = slugs.length ? await db.sortedSetScores('userslug:uid', slugs) : [];
|
|
125
|
+
uidsToNotify = uidsToNotify.map(String);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
if ((!uidsToNotify && !groupsToNotify) || (!uidsToNotify.length && !groupsToNotify.length)) {
|
|
131
129
|
return;
|
|
132
130
|
}
|
|
133
131
|
|
|
134
|
-
|
|
132
|
+
const [topic, userData, topicFollowers] = await Promise.all([
|
|
135
133
|
Topics.getTopicFields(post.tid, ['title', 'cid']),
|
|
136
134
|
User.getUserFields(post.uid, ['username']),
|
|
137
135
|
Mentions._settings.disableFollowedTopics === 'on' ? Topics.getFollowers(post.tid) : [],
|
|
@@ -139,10 +137,9 @@ Mentions.notify = async function ({ post }) {
|
|
|
139
137
|
const { displayname } = userData;
|
|
140
138
|
const title = entitiesDecode(topic.title);
|
|
141
139
|
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
|
142
|
-
topicFollowers = topicFollowers.map(uid => parseInt(uid, 10));
|
|
143
140
|
|
|
144
141
|
let uids = uidsToNotify.filter(
|
|
145
|
-
uid =>
|
|
142
|
+
uid => uid !== postOwner && !topicFollowers.includes(uid)
|
|
146
143
|
);
|
|
147
144
|
|
|
148
145
|
if (Mentions._settings.privilegedDirectReplies === 'on') {
|
|
@@ -158,7 +155,7 @@ Mentions.notify = async function ({ post }) {
|
|
|
158
155
|
}
|
|
159
156
|
groupMemberUids[uid] = 1;
|
|
160
157
|
return !uids.includes(uid) &&
|
|
161
|
-
|
|
158
|
+
uid !== postOwner &&
|
|
162
159
|
!topicFollowers.includes(uid);
|
|
163
160
|
});
|
|
164
161
|
});
|
package/package.json
CHANGED
package/static/.eslintrc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "nodebb/public"
|
|
3
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "nodebb/public"
|
|
3
|
+
}
|