From 58d09aafb35dbd034b13de4f1b7299c3154bb9d7 Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 5 Mar 2020 13:13:42 -0500 Subject: messagesByType: support sort by claimed timestamp --- lib/app.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/app.js b/lib/app.js index 03e3010..f223745 100644 --- a/lib/app.js +++ b/lib/app.js @@ -1307,8 +1307,19 @@ App.prototype.sbotCreateUserStream = function (opts) { } App.prototype.sbotMessagesByType = function (opts) { - if (!this.sbot.messagesByType) return pull.error(new Error('missing sbot.messagesByType')) - return this.sbot.messagesByType(opts) + if (opts.sortByTimestamp) { + if (!this.sbot.query) { + return pull.error(new Error('missing ssb-query')) + } + return this.filter(this.sbot.query, opts, { + value: {content: {type: opts.type}} + }) + } else { + if (!this.sbot.messagesByType) { + return pull.error(new Error('missing sbot.messagesByType')) + } + return this.sbot.messagesByType(opts) + } } App.prototype.getThread = function (msg) { -- cgit v1.2.3