nodebb-plugin-mentions 4.4.2 → 4.4.4

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 +4 -4
  2. package/package.json +2 -2
package/library.js CHANGED
@@ -105,7 +105,7 @@ Mentions.notify = async function ({ post }) {
105
105
  const { tag } = post._activitypub;
106
106
  groupsToNotify = []; // cannot mention groups for now
107
107
 
108
- if (tag.length) {
108
+ if (Array.isArray(tag) && tag.length) {
109
109
  const slugs = tag.reduce((slugs, tag) => {
110
110
  if (tag.type === 'Mention') {
111
111
  const [slug, hostname] = tag.name.slice(1).split('@');
@@ -395,13 +395,13 @@ Mentions.parseRaw = async (content) => {
395
395
  const uid = await User.getUidByUserslug(slug);
396
396
  const { groupExists, user } = await utils.promiseParallel({
397
397
  groupExists: Groups.existsBySlug(slug),
398
- user: User.getUserFields(uid, ['uid', 'username', 'fullname']),
398
+ user: User.getUserFields(uid, ['uid', 'username', 'fullname', 'url']),
399
399
  });
400
400
 
401
401
  if (user.uid || groupExists) {
402
402
  let url;
403
403
  if (user.uid) {
404
- url = utils.isNumber(user.uid) ? `${nconf.get('url')}/uid/${user.uid}` : user.uid;
404
+ url = utils.isNumber(user.uid) ? `${nconf.get('url')}/uid/${user.uid}` : (user.url || user.uid);
405
405
  } else {
406
406
  url = `${nconf.get('url')}/groups/${slug}`;
407
407
  }
@@ -432,7 +432,7 @@ Mentions.parseRaw = async (content) => {
432
432
  }
433
433
  }
434
434
 
435
- const str = `<a class="mention plugin-mentions-${user.uid ? 'user' : 'group'} plugin-mentions-a" href="${url}">${match}</a>`;
435
+ const str = `<a class="plugin-mentions-${user.uid ? 'user' : 'group'} plugin-mentions-a" href="${url}">${match}</a>`;
436
436
 
437
437
  return plain + str;
438
438
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.4.2",
3
+ "version": "4.4.4",
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
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "validator": "^13.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "mocha": "10.3.0",
33
+ "mocha": "10.4.0",
34
34
  "eslint": "8.57.0",
35
35
  "eslint-config-nodebb": "0.2.1",
36
36
  "eslint-plugin-import": "2.29.1"