diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-01-28 21:16:01 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-01-29 00:20:15 -1000 |
commit | f32665ca5d41f1022f1883c573c5dd680ddca452 (patch) | |
tree | de4105b5458e015a199c40dd61c4c6a24f83e077 /lib | |
parent | f82b1f2775b7eafc92f8cf7db98c140742f78b4d (diff) | |
download | patchfoo-f32665ca5d41f1022f1883c573c5dd680ddca452.tar.gz patchfoo-f32665ca5d41f1022f1883c573c5dd680ddca452.zip |
Add block page
Allow composing a block message with a reason.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js index c583f90..d702ee6 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -229,6 +229,7 @@ Serve.prototype.requestReplicate = function (id, 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) + if (this.data.block1) return this.redirect(this.app.render.toUrl('/block/' + this.data.contact)) var content = { type: 'contact', contact: this.data.contact, @@ -411,6 +412,7 @@ Serve.prototype.path = function (url) { case '/shard': return this.shard(m[2]) case '/zip': return this.zip(m[2]) case '/web': return this.web(m[2]) + case '/block': return this.block(m[2]) case '/script': return this.script(m[2]) } return this.respond(404, 'Not found') @@ -1119,6 +1121,44 @@ Serve.prototype.aboutSelf = function (ext) { }) } +Serve.prototype.block = function (path) { + var self = this + var data = self.data + var id = String(path).substr(1) + try { id = decodeURIComponent(id) } + catch(e) {} + + var content + if (data.preview || data.preview_raw) { + content = { + type: 'contact', + contact: id, + blocking: true + } + var reason = typeof data.reason === 'string' ? data.reason : null + if (reason) content.reason = reason + } + + pull( + ph('section', [ + ph('h2', ['Block ', self.phIdLink(id)]), + ph('form', {action: '', method: 'post', enctype: 'multipart/form-data'}, [ + 'Reason: ', ph('input', {name: 'reason', value: reason || '', + style: 'width: 100%', + placeholder: 'spam, abuse, etc.'}), + ph('p', {class: 'msg-right'}, [ + ph('input', {type: 'submit', name: 'preview_raw', value: 'Raw'}), ' ', + ph('input', {type: 'submit', name: 'preview', value: 'Preview'}) + ]) + ]), + content ? [ + self.phPreview(content, {raw: data.preview_raw}) + ] : '' + ]), + self.wrapPage('Block ' + id), + self.respondSink(200) + ) +} Serve.prototype.type = function (path) { var q = this.query @@ -1789,9 +1829,9 @@ Serve.prototype.followInfo = function (id, myId) { ph('input', {type: 'submit', name: contactToThem ? 'unfollow' : 'follow', value: contactToThem ? 'unfollow' : 'follow'}), ' ', - ph('input', {type: 'submit', - name: contactToThem === false ? 'unblock' : 'block', - value: contactToThem === false ? 'unblock' : 'block'}), ' ', + contactToThem === false + ? ph('input', {type: 'submit', name: 'unblock', value: 'unblock'}) + : ph('input', {type: 'submit', name: 'block1', value: 'blockā¦'}), ' ', ph('input', {type: 'submit', name: isMuted ? 'unmute' : 'mute', value: isMuted ? 'unmute' : 'mute', |