Procházet zdrojové kódy

Bugfix. Filter out references without uri

JC Brand před 11 měsíci
rodič
revize
e4b9c7eabf

+ 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) {
 function isReferenced (references, muc_jid, nick) {
     const bare_jid = _converse.session.get('bare_jid');
     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?
  * Is this a group message for which we should notify the user?
- * @param { MUCMessageAttributes } attrs
+ * @param {MUCMessageAttributes} attrs
  */
  */
 export async function shouldNotifyOfGroupMessage (attrs) {
 export async function shouldNotifyOfGroupMessage (attrs) {
     if (!attrs?.body && !attrs?.message) {
     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;
 export function updateUnreadFavicon(): void;
 /**
 /**
  * Is this a group message for which we should notify the user?
  * 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 shouldNotifyOfGroupMessage(attrs: any): Promise<any>;
 export function showFeedbackNotification(data: any): void;
 export function showFeedbackNotification(data: any): void;