Fix the write note page.
This commit is contained in:
parent
6245578f1b
commit
e027336e2b
10
render.js
10
render.js
|
@ -428,7 +428,7 @@ const UI = {
|
|||
addCcRecipient: function() {
|
||||
const actor = new Actor()
|
||||
actor.loadFromNameServerAddress(
|
||||
Elem('send-message-to-recipient').value,
|
||||
Elem('send-message-cc-recipient').value,
|
||||
function(load_ok, failure_message) {
|
||||
if (load_ok) {
|
||||
UI.composed_message.addCcRecipient(actor)
|
||||
|
@ -441,16 +441,14 @@ const UI = {
|
|||
// Remove from To
|
||||
removeToRecipient: function(url_profile) {
|
||||
// Don't fetch the actor, only set the profile url used in removal
|
||||
const actor = new Actor()
|
||||
actor.data.id = url_profile
|
||||
const actor = {data: {id: url_profile}}
|
||||
UI.composed_message.removeToRecipient(actor)
|
||||
UI.showPage('send-message', undefined)
|
||||
},
|
||||
// Remove from Cc
|
||||
removeCcRecipient: function(url_profile) {
|
||||
// Don't fetch the actor, only set the profile url used in removal
|
||||
const actor = new Actor()
|
||||
actor.data.id = url_profile
|
||||
const actor = {data: {id: url_profile}}
|
||||
UI.composed_message.removeCcRecipient(actor)
|
||||
UI.showPage('send-message', undefined)
|
||||
},
|
||||
|
@ -463,6 +461,8 @@ const UI = {
|
|||
UI.composed_message.send(
|
||||
function(is_ok, failure_message) {
|
||||
if (is_ok) {
|
||||
// Clear message
|
||||
UI.composed_message = new Message()
|
||||
UI.showPage('send-message', undefined)
|
||||
} else {
|
||||
UI.displayError('Error when sending message: ' + failure_message)
|
||||
|
|
|
@ -34,13 +34,13 @@ Message.prototype = {
|
|||
},
|
||||
// Remove recipients
|
||||
removeToRecipient: function(actor) {
|
||||
var idx = this.to.findIndex(x => x.urls.profile === actor.urls.profile)
|
||||
var idx = this.to.findIndex(x => x.data.id === actor.data.id)
|
||||
if (idx !== -1) {
|
||||
this.to.splice(idx, 1)
|
||||
}
|
||||
},
|
||||
removeCcRecipient: function(actor) {
|
||||
var idx = this.cc.findIndex(x => x.urls.profile === actor.urls.profile)
|
||||
var idx = this.cc.findIndex(x => x.data.id === actor.data.id)
|
||||
if (idx !== -1) {
|
||||
this.cc.splice(idx, 1)
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ Message.prototype = {
|
|||
// Send message
|
||||
send: function(callback) {
|
||||
// Recipients
|
||||
var recipients_to = this.to.map(x => x.urls.profile)
|
||||
var recipients_cc = this.cc.map(x => x.urls.profile)
|
||||
var recipients_to = this.to.map(x => x.data.id)
|
||||
var recipients_cc = this.cc.map(x => x.data.id)
|
||||
if (this.public_visibility === 'to') {
|
||||
recipients_to.push('https://www.w3.org/ns/activitystreams#Public')
|
||||
} else if (this.public_visibility === 'cc') {
|
||||
recipients_cc.push('https://www.w3.org/ns/activitystreams#Public')
|
||||
}
|
||||
if (this.follower_visibility === 'to') {
|
||||
recipients_to.push(ConnectedUser.actor.urls.followers)
|
||||
recipients_to.push(ConnectedUser.actor.data.followers)
|
||||
} else if (this.follower_visibility === 'cc') {
|
||||
recipients_cc.push(ConnectedUser.actor.urls.followers)
|
||||
recipients_cc.push(ConnectedUser.actor.data.followers)
|
||||
}
|
||||
//
|
||||
var message = {
|
||||
|
@ -87,7 +87,7 @@ Message.prototype = {
|
|||
callback(false, 'Send: Message not created on server')
|
||||
}
|
||||
}
|
||||
request.open('POST', ConnectedUser.actor.urls.outbox, true)
|
||||
request.open('POST', ConnectedUser.actor.data.outbox, true)
|
||||
request.setRequestHeader('Authorization', 'Bearer ' + ConnectedUser.tokens.user.access_token)
|
||||
request.setRequestHeader('Content-Type', 'application/activity+json')
|
||||
request.setRequestHeader('Accept', 'application/activity+json')
|
||||
|
|
Loading…
Reference in New Issue