aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/render-msg.js29
-rw-r--r--lib/serve.js20
2 files changed, 39 insertions, 10 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 5b32fdd..003c1bf 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -148,7 +148,9 @@ RenderMsg.prototype.actions = function () {
this.c.type === 'gathering' ? [
h('a', {href: this.render.toUrl('/about/' + encodeURIComponent(this.msg.key))}, 'about'), ' '] : '',
h('a', {href: this.toUrl(this.msg.key) + '?raw'}, 'raw'), ' ',
- this.voteFormInner('dig')
+ this.buttonsCommon(),
+ this.c.type === 'gathering' ? [this.attendButton(), ' '] : '',
+ this.voteButton('dig')
) : [
this.msg.rel ? [this.msg.rel, ' '] : ''
]
@@ -175,16 +177,29 @@ RenderMsg.prototype.recpsIds = function () {
: []
}
-RenderMsg.prototype.voteFormInner = function (expression) {
+RenderMsg.prototype.buttonsCommon = function () {
var chan = this.msg.value.content.channel
+ var recps = this.recpsIds()
return [
- h('input', {type: 'hidden', name: 'action', value: 'vote'}),
- h('input', {type: 'hidden', name: 'recps',
- value: this.recpsIds().join(',')}),
chan ? h('input', {type: 'hidden', name: 'channel', value: chan}) : '',
h('input', {type: 'hidden', name: 'link', value: this.msg.key}),
- h('input', {type: 'hidden', name: 'value', value: 1}),
- h('input', {type: 'submit', name: 'expression', value: expression})]
+ h('input', {type: 'hidden', name: 'recps', value: recps.join(',')})
+ ]
+}
+
+RenderMsg.prototype.voteButton = function (expression) {
+ var chan = this.msg.value.content.channel
+ return [
+ h('input', {type: 'hidden', name: 'vote_value', value: 1}),
+ h('input', {type: 'hidden', name: 'vote_expression', value: expression}),
+ h('input', {type: 'submit', name: 'action_vote', value: expression})]
+}
+
+RenderMsg.prototype.attendButton = function () {
+ var chan = this.msg.value.content.channel
+ return [
+ h('input', {type: 'submit', name: 'action_attend', value: 'attend'})
+ ]
}
RenderMsg.prototype.message = function (cb) {
diff --git a/lib/serve.js b/lib/serve.js
index 1909bbc..e0d9396 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -122,9 +122,10 @@ Serve.prototype.go = function () {
self.data = data
if (err) next(err)
else if (data.action === 'publish') self.publishJSON(next)
- else if (data.action === 'vote') self.publishVote(next)
else if (data.action === 'contact') self.publishContact(next)
else if (data.action === 'want-blobs') self.wantBlobs(next)
+ else if (data.action_vote) self.publishVote(next)
+ else if (data.action_attend) self.publishAttend(next)
else next()
}
@@ -161,8 +162,8 @@ Serve.prototype.publishVote = function (cb) {
channel: this.data.channel || undefined,
vote: {
link: this.data.link,
- value: Number(this.data.value),
- expression: this.data.expression,
+ value: Number(this.data.vote_value),
+ expression: this.data.vote_expression,
}
}
if (this.data.recps) content.recps = this.data.recps.split(',')
@@ -178,6 +179,19 @@ Serve.prototype.publishContact = function (cb) {
this.publish(content, cb)
}
+Serve.prototype.publishAttend = function (cb) {
+ var content = {
+ type: 'about',
+ channel: this.data.channel || undefined,
+ about: this.data.link,
+ attendee: {
+ link: this.app.sbot.id
+ }
+ }
+ if (this.data.recps) content.recps = this.data.recps.split(',')
+ this.publish(content, cb)
+}
+
Serve.prototype.wantBlobs = function (cb) {
var self = this
if (!self.data.blob_ids) return cb()