nodebb-plugin-mentions 4.7.0 → 4.7.2

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.
Files changed (2) hide show
  1. package/library.js +9 -12
  2. package/package.json +2 -2
package/library.js CHANGED
@@ -81,7 +81,7 @@ function getNoMentionGroups() {
81
81
  }
82
82
 
83
83
  Mentions.notify = async function ({ post }) {
84
- const postOwner = parseInt(post.uid, 10);
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
- const slugs = tag.reduce((slugs, tag) => {
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
- let [topic, userData, topicFollowers] = await Promise.all([
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 => parseInt(uid, 10) !== postOwner && !topicFollowers.includes(parseInt(uid, 10))
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
- parseInt(uid, 10) !== postOwner &&
158
+ uid !== postOwner &&
162
159
  !topicFollowers.includes(uid);
163
160
  });
164
161
  });
@@ -492,7 +489,7 @@ Mentions.parseRaw = async (content, type = 'default') => {
492
489
  if (type === 'markdown') {
493
490
  str = `[${match}](${nconf.get('url')}${url})`;
494
491
  } else {
495
- str = `<a class="plugin-mentions-${mentionType} plugin-mentions-a" href="${url}">${match}</a>`;
492
+ str = `<a class="plugin-mentions-${mentionType} plugin-mentions-a" href="${url}">@<bdi>${match.slice(1)}</bdi></a>`;
496
493
  }
497
494
 
498
495
  return plain + str;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.7.0",
3
+ "version": "4.7.2",
4
4
  "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "eslint": "^9.0.0",
31
- "eslint-config-nodebb": "0.2.1",
31
+ "eslint-config-nodebb": "1.0.7",
32
32
  "eslint-plugin-import": "2.31.0",
33
33
  "mocha": "11.1.0"
34
34
  }