From ba5b68142c6759e3e48ff2837c578a2deaa0ca8d Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 28 Jan 2019 19:14:13 -1000 Subject: Handle old-style auto-follow --- lib/render-msg.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index 2af4bca..9e33be6 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -709,12 +709,23 @@ RenderMsg.prototype.aboutRating = function (cb) { RenderMsg.prototype.contact = function (cb) { var self = this + + // In message content, autofollow:true means following a pub in connection with using an invite code to it. pub:true means the author is a pub, responding to an invite code. But I think it makes more sense to switch the terms and call the follow from the pub auto-follow, since the pub does it automatically, and the follow from the one using an invite code pub-follow ("X follows pub Y") since it is to follow a pub. + // In scuttlebot before v8.4.0 (1ac0b9cf8214899baf0ba7ff4c0924d21a1b48cf), autofollow:true was used for both kinds of follows. We can detect that using the timestamp and/or the order of keys. + + var pubFollow = self.c.following && self.c.autofollow + var autoFollow = self.c.following && self.c.pub + if (pubFollow && self.msg.value.timestamp < 1469361582000 + && Object.keys(self.c).join() === 'type,contact,following,autofollow') { + pubFollow = false + autoFollow = true + } self.link(self.c.contact, function (err, a) { if (err) return cb(err) if (!a) a = "?" self.wrapMini([ - self.c.following && self.c.autofollow ? 'follows pub' : - self.c.following && self.c.pub ? 'autofollows' : + pubFollow ? 'follows pub' : + autoFollow ? 'autofollows' : self.c.following ? 'follows' : self.c.blocking ? 'blocks' : self.c.flagged ? 'flagged' : -- cgit v1.2.3