瀏覽代碼

Bugfix. Filter out references without uri

JC Brand 11 月之前
父節點
當前提交
e4b9c7eabf
共有 2 個文件被更改,包括 9 次插入4 次删除
  1. 8 3
      src/plugins/notifications/utils.js
  2. 1 1
      src/types/plugins/notifications/utils.d.ts

+ 8 - 3
src/plugins/notifications/utils.js

@@ -52,16 +52,21 @@ export function updateUnreadFavicon () {
 }
 
 
+/**
+ * @param {Array<Object>} references - A list of objects representing XEP-0372 references
+ * @param {string} muc_jid
+ * @param {string} nick
+ */
 function isReferenced (references, muc_jid, nick) {
     const bare_jid = _converse.session.get('bare_jid');
-    const check = r => [bare_jid, `${muc_jid}/${nick}`].includes(r.uri.replace(/^xmpp:/, ''));
-    return references.reduce((acc, r) => acc || check(r), false);
+    const check = (r) => [bare_jid, `${muc_jid}/${nick}`].includes(r.uri.replace(/^xmpp:/, ''));
+    return references.reduce((acc, r) => (acc || (r.uri && check(r))), false);
 }
 
 
 /**
  * Is this a group message for which we should notify the user?
- * @param { MUCMessageAttributes } attrs
+ * @param {MUCMessageAttributes} attrs
  */
 export async function shouldNotifyOfGroupMessage (attrs) {
     if (!attrs?.body && !attrs?.message) {

+ 1 - 1
src/types/plugins/notifications/utils.d.ts

@@ -7,7 +7,7 @@ export function clearFavicon(): void;
 export function updateUnreadFavicon(): void;
 /**
  * Is this a group message for which we should notify the user?
- * @param { MUCMessageAttributes } attrs
+ * @param {MUCMessageAttributes} attrs
  */
 export function shouldNotifyOfGroupMessage(attrs: any): Promise<any>;
 export function showFeedbackNotification(data: any): void;