From 9e8d0e233976548059b67f9942f8ca2236088b8d Mon Sep 17 00:00:00 2001 From: subham103 Date: Thu, 12 Mar 2020 18:57:41 +0530 Subject: [PATCH 1/2] [IMPROVE] add option for description and title search --- server/methods/messageSearch.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/methods/messageSearch.js b/server/methods/messageSearch.js index f58674c598ef..f8c7a98e562c 100644 --- a/server/methods/messageSearch.js +++ b/server/methods/messageSearch.js @@ -117,6 +117,16 @@ Meteor.methods({ return ''; } + function filterTitle(_, tag) { + query['attachments.0.title'] = new RegExp(s.escapeRegExp(tag), 'i'); + return ''; + } + + function filterDescription(_, tag) { + query['attachments.description'] = new RegExp(s.escapeRegExp(tag), 'i'); + return ''; + } + function sortByTimestamp(_, direction) { if (direction.startsWith('asc')) { options.sort.ts = 1; @@ -171,6 +181,10 @@ Meteor.methods({ text = text.replace(/has:location|has:map/g, filterLocation); // Filter image tags text = text.replace(/label:(\w+)/g, filterLabel); + // Filter on description of messages. + text = text.replace(/desc:(\w+)/g, filterDescription); + // Filter on title of messages. + text = text.replace(/title:(\w+)/g, filterTitle); // Filtering before/after/on a date // matches dd-MM-yyyy, dd/MM/yyyy, dd-MM-yyyy, prefixed by before:, after: and on: respectively. // Example: before:15/09/2016 after: 10-08-2016 From 08b9bef7677324a965d8b8c38228a872db10b539 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 20 Apr 2020 16:03:15 -0300 Subject: [PATCH 2/2] Apply suggestions from code review --- server/methods/messageSearch.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/methods/messageSearch.js b/server/methods/messageSearch.js index f8c7a98e562c..e0fb9f394541 100644 --- a/server/methods/messageSearch.js +++ b/server/methods/messageSearch.js @@ -118,7 +118,7 @@ Meteor.methods({ } function filterTitle(_, tag) { - query['attachments.0.title'] = new RegExp(s.escapeRegExp(tag), 'i'); + query['attachments.title'] = new RegExp(s.escapeRegExp(tag), 'i'); return ''; } @@ -182,9 +182,9 @@ Meteor.methods({ // Filter image tags text = text.replace(/label:(\w+)/g, filterLabel); // Filter on description of messages. - text = text.replace(/desc:(\w+)/g, filterDescription); + text = text.replace(/file-desc:(\w+)/g, filterDescription); // Filter on title of messages. - text = text.replace(/title:(\w+)/g, filterTitle); + text = text.replace(/file-title:(\w+)/g, filterTitle); // Filtering before/after/on a date // matches dd-MM-yyyy, dd/MM/yyyy, dd-MM-yyyy, prefixed by before:, after: and on: respectively. // Example: before:15/09/2016 after: 10-08-2016