aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 3b56da7..bac3d53 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -977,6 +977,46 @@ App.prototype.getAddresses = function (id) {
)
}
+App.prototype.isPub = function (id, cb) {
+ if (!this.sbot.backlinks) {
+ return pull(
+ this.sbot.links({
+ dest: id,
+ rel: 'pub'
+ }),
+ pull.take(1),
+ pull.collect(function (err, links) {
+ if (err) return cb(err)
+ cb(null, links.length == 1)
+ })
+ )
+ }
+ return pull(
+ this.sbot.backlinks.read({
+ limit: 1,
+ query: [
+ {$filter: {
+ dest: id,
+ value: {
+ content: {
+ type: 'pub',
+ address: {
+ key: id,
+ host: {$truthy: true},
+ port: {$truthy: true},
+ }
+ }
+ }
+ }}
+ ]
+ }),
+ pull.collect(function (err, msgs) {
+ if (err) return cb(err)
+ cb(null, msgs.length == 1)
+ })
+ )
+}
+
App.prototype.getIdeaTitle = function (id, cb) {
if (!this.sbot.backlinks) return cb(null, String(id).substr(0, 8) + '…')
pull(