Add dummy actors for followers to display those correctly in To/Cc fields

This commit is contained in:
Feufochmar 2020-03-26 12:15:44 +01:00
parent 95c9c81da1
commit 3c24c61e1e
2 changed files with 24 additions and 6 deletions

View File

@ -21,9 +21,9 @@ var UI = {
display = display + '<img src="' + actor.info.icon + '" width="32" height="32" /> '
}
display = display
+ '<p style="display:inline-block;"><strong>' + actor.info.display_name + '</strong> <br/>'
+ '<p style="display:inline-block;"><strong>' + actor.displayName() + '</strong> <br/>'
+ '<a href="' + actor.urls.profile + '">'
+ actor.name + '@' + actor.server
+ actor.address()
+ '</a></p>'
} else {
display = display
@ -320,9 +320,9 @@ var UI = {
display = display + '<img src="' + actor.info.icon + '" width="96" height="96" /> '
}
display = display
+ '<p style="display:inline-block;"><strong>' + actor.info.display_name + '</strong> <br/>'
+ '<p style="display:inline-block;"><strong>' + actor.displayName() + '</strong> <br/>'
+ '<a href="' + actor.urls.profile + '">'
+ actor.name + '@' + actor.server
+ actor.address()
+ '</a></p>'
+ '<p>' + actor.info.summary + '</p>'
} else {
@ -333,7 +333,7 @@ var UI = {
+ '</a></p>'
}
display = display + '</section>'
if (actor.valid) {
if (actor.raw) {
display = display + UI.renderRawData(actor.raw)
}
return display

View File

@ -2,12 +2,30 @@ const {Actor} = require('./actor.js')
// A cache for actors, to avoid loading same actors several times when loading timelines
var KnownActors = {
// Cache of real actors
actors: {},
// Cache of followers' collection of actors, as they can be recipients of messages
followers: {},
// Methods
get: function(profile) {
return KnownActors.actors[profile]
var act = KnownActors.actors[profile]
if (!act) {
act = KnownActors.followers[profile]
}
return act
},
set: function(profile, actor) {
KnownActors.actors[profile] = actor
// Make a false actor for followers
if (actor.urls.followers) {
var followers = new Actor()
followers.valid = true
followers.name = 'followers:' + actor.name
followers.server = actor.server
followers.info.display_name = "Followers of " + actor.displayName()
followers.urls.profile = actor.urls.followers
KnownActors.followers[actor.urls.followers] = followers;
}
},
// Retrieve an actor
retrieve: function(profile, callback) {