Skip to content

Node.js based forum software built for the modern web

filter:topics.searchTags

barisusaklid0a94cb86cf5
diff --git a/src/topics/tags.js b/src/topics/tags.js
index 13dcd4b14d..50db8ccede 100644
--- a/src/topics/tags.js
+++ b/src/topics/tags.js
@@ -263,13 +263,29 @@ module.exports = function(Topics) {
};
Topics.searchTags = function(data, callback) {
+ function done(matches) {
+ plugins.fireHook('filter:tags.search', {data: data, matches: matches}, function(err, data) {
+ callback(err, data ? data.matches : []);
+ });
+ }
+
+
if (!data || !data.query) {
return callback(null, []);
}
+ if (plugins.hasListeners('filter:topics.searchTags')) {
+ return plugins.fireHook('filter:topics.searchTags', {data: data}, function(err, data) {
+ if (err) {
+ return callback(err);
+ }
+ done(data.matches);
+ });
+ }
+
db.getSortedSetRevRange('tags:topic:count', 0, -1, function(err, tags) {
if (err) {
- return callback(null, []);
+ return callback(err);
}
data.query = data.query.toLowerCase();
@@ -285,9 +301,7 @@ module.exports = function(Topics) {
return a > b;
});
- plugins.fireHook('filter:tags.search', {data: data, matches: matches}, function(err, data) {
- callback(err, data ? data.matches : []);
- });
+ done(matches);
});
};