aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-03-24 14:10:02 -0400
committercel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-03-28 13:55:28 -0400
commita7f5b23b2eb2b101fd1bb40cb77fbf879dc6fd0f (patch)
treebd97dad6b638c0c16c8d6ed39a82aab8f7af5bac
parentc7d4f7024cd5cce7a5fbf064decec6414e54344c (diff)
downloadpatchfoo-a7f5b23b2eb2b101fd1bb40cb77fbf879dc6fd0f.tar.gz
patchfoo-a7f5b23b2eb2b101fd1bb40cb77fbf879dc6fd0f.zip
new gathering: put mentions in gathering root
-rw-r--r--lib/serve.js58
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 9515ce3..452cad4 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -169,7 +169,7 @@ Serve.prototype.go = function () {
function gotData(err, data) {
self.data = data
if (err) next(err)
- else if (data.action === 'publish' && data.about_new) self.publishNewAbout(next)
+ else if (data.action === 'publish' && data.about_new_content) self.publishNewAbout(next)
else if (data.action === 'publish') self.publishJSON(next)
else if (data.action === 'contact') self.publishContact(next)
else if (data.action === 'want-blobs') self.wantBlobs(next)
@@ -226,20 +226,18 @@ Serve.prototype.publishJSON = function (cb) {
Serve.prototype.publishNewAbout = function (cb) {
var self = this
- var aboutContent
+ var aboutContent, aboutNewContent
try {
aboutContent = JSON.parse(this.data.content)
+ aboutNewContent = JSON.parse(this.data.about_new_content)
} catch(e) {
return cb(e)
}
if (typeof aboutContent !== 'object' || aboutContent === null) {
return cb(new TypeError('content must be object'))
}
- var newContent = {
- type: this.data.about_new,
- recps: aboutContent.recps
- }
- self.app.publish(newContent, function (err, msg) {
+ aboutNewContent.recps = aboutContent.recps
+ self.app.publish(aboutNewContent, function (err, msg) {
if (err) return cb(err)
if (!msg) return cb(new Error('aborted'))
aboutContent.about = msg.key
@@ -1599,8 +1597,7 @@ Serve.prototype.newGathering = function () {
} : null
var selfAttending = Boolean(data.attending)
- var additionalMentions = data.mentions ? u.extractRefs(data.mentions) : []
- var mentions = additionalMentions.slice(0)
+ var initialMentions = data.mentions ? u.extractRefs(data.mentions) : []
var content
if (data.preview || data.preview_raw) {
@@ -1613,20 +1610,20 @@ Serve.prototype.newGathering = function () {
if (image) content.image = image
if (description) {
content.description = description
- var textMentions = ssbMentions(description, {bareFeedNames: false, emoji: false})
- textMentions.forEach(function (link) {
- if (mentions.indexOf(link.link) === -1) {
- mentions.push(link)
- }
- })
+ var mentions = ssbMentions(description, {bareFeedNames: false, emoji: false})
+ if (mentions.length) content.mentions = mentions
}
if (startDateTime) content.startDateTime = startDateTime
- if (mentions.length) content.mentions = mentions
if (selfAttending) content.attendee = {
link: selfId
}
}
+ var aboutNewContent = {
+ type: 'gathering',
+ mentions: initialMentions.length ? initialMentions : undefined
+ }
+
var startDateTimeStr = ''
if (startDateTime) try {
startDateTimeStr = new Date(startDateTime.epoch).toISOString().replace(/ .*/, '')
@@ -1707,14 +1704,17 @@ Serve.prototype.newGathering = function () {
' attending'
])),
ph('div', ph('textarea', {
- name: 'mentions', placeholder: 'Additional mentions',
- title: 'SSB feed/blob/message IDs to mention besides those in the description',
+ name: 'mentions', placeholder: 'Initial mentions',
+ title: 'SSB feed/blob/message IDs to mention in the gathering root message',
cols: 70, style: 'font: monospace',
- rows: Math.max(3, additionalMentions.length + 2),
- }, u.escapeHTML(additionalMentions.join('\n')))),
+ rows: Math.max(3, initialMentions.length + 2),
+ }, u.escapeHTML(initialMentions.join('\n')))),
self.phMsgActions(content)
]),
- content ? self.phPreview(content, {raw: data.preview_raw, aboutNew: 'gathering'}) : ''
+ content ? self.phPreview(content, {
+ raw: data.preview_raw,
+ aboutNewContent: aboutNewContent
+ }) : ''
]),
self.wrapPage('New Gathering'),
self.respondSink(200)
@@ -4735,20 +4735,18 @@ Serve.prototype.phPreview = function (content, opts) {
var estSize = u.estimateMessageSize(content)
if (estSize > 8192) warnings.push(ph('li', 'message is too long'))
- var aboutNewType = opts.aboutNew, aboutNewMsg
- if (aboutNewType) {
+ var aboutNewContent = opts.aboutNewContent, aboutNewMsg
+ if (aboutNewContent) {
aboutNewMsg = {
value: {
author: this.app.sbot.id,
timestamp: Date.now(),
- content: {
- type: aboutNewType
- }
+ content: aboutNewContent
}
}
// this duplicates functionality in publishNewAbout, for display purposes
if (content.recps) {
- aboutNewMsg.value.content.recps = content.recps
+ aboutNewContent.recps = content.recps
aboutNewMsg.value.private = true
}
}
@@ -4764,7 +4762,9 @@ Serve.prototype.phPreview = function (content, opts) {
u.escapeHTML(this.app.render.formatSize(estSize))
]),
ph('table', {class: 'ssb-msgs'}, pull(
- pull.once(msg),
+ aboutNewMsg
+ ? pull.values([aboutNewMsg, msg])
+ : pull.once(msg),
this.app.unboxMessages(),
this.app.render.renderFeeds({
serve: self,
@@ -4774,7 +4774,7 @@ Serve.prototype.phPreview = function (content, opts) {
pull.map(u.toHTML)
)),
ph('input', {type: 'hidden', name: 'content', value: u.escapeHTML(JSON.stringify(content))}),
- aboutNewType ? ph('input', {type: 'hidden', name: 'about_new', value: u.escapeHTML(aboutNewType)}) : null,
+ aboutNewContent ? ph('input', {type: 'hidden', name: 'about_new_content', value: u.escapeHTML(JSON.stringify(aboutNewContent))}) : null,
ph('div', {class: 'composer-actions'}, [
ph('input', {type: 'submit', name: 'action', value: 'publish'})
])