Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Add file-title and file-desc as new filter tag options on message search #16858

Merged
merged 3 commits into from
Apr 21, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions server/methods/messageSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ Meteor.methods({
return '';
}

function filterTitle(_, tag) {
query['attachments.0.title'] = new RegExp(s.escapeRegExp(tag), 'i');
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand Down Expand Up @@ -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);
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
// Filter on title of messages.
text = text.replace(/title:(\w+)/g, filterTitle);
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
// 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
Expand Down