From f82b1f2775b7eafc92f8cf7db98c140742f78b4d Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 28 Jan 2019 20:44:46 -1000 Subject: Add replicate.request button --- lib/serve.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/serve.js b/lib/serve.js index 7eefc9f..c583f90 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -210,7 +210,25 @@ Serve.prototype.publishVote = function (next) { } } +Serve.prototype.requestReplicate = function (id, replicateIt, next) { + var self = this + var replicate = self.app.sbot.replicate + var request = replicate && replicate.request + if (!request) return this.respond(500, 'Missing replicate.request method') + request(id, replicateIt, function (err) { + if (err) return pull( + pull.once(u.renderError(err, ext).outerHTML), + self.wrapPage('replicate request'), + self.respondSink(400) + ) + self.requestedReplicate = replicateIt + next() + }) +} + Serve.prototype.publishContact = function (next) { + if (this.data.replicate) return this.requestReplicate(this.data.contact, true, next) + if (this.data.unreplicate) return this.requestReplicate(this.data.contact, false, next) var content = { type: 'contact', contact: this.data.contact, @@ -1777,7 +1795,13 @@ Serve.prototype.followInfo = function (id, myId) { ph('input', {type: 'submit', name: isMuted ? 'unmute' : 'mute', value: isMuted ? 'unmute' : 'mute', - title: isMuted ? 'unmute (private unblock)' : 'mute (private block)'}) + title: isMuted ? 'unmute (private unblock)' : 'mute (private block)'}), ' ', + ph('input', {type: 'submit', + name: self.requestedReplicate ? 'unreplicate' : 'replicate', + value: self.requestedReplicate ? 'unreplicate' : 'replicate', + title: self.requestedReplicate + ? 'Temporarily cancel replicating this feed' + : 'Temporarily replicate this feed'}) ])) }) }) -- cgit v1.2.3