aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js46
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',