import { sequelizeTypescript } from '../../initializers/database'
import {
MAccount,
+ MAccountDefault,
MActor,
MActorAccountChannelId,
+ MActorAccountChannelIdActor,
MActorAccountId,
MActorDefault,
MActorFull,
+ MActorFullActor,
MActorId,
- MActorAccountChannelIdActor,
MChannel,
- MActorFullActor, MAccountActorDefault, MChannelActorDefault, MChannelActorAccountDefault
+ MChannelAccountDefault
} from '../../typings/models'
// Set account keys, this could be long so process after the account creation and do not block the client
-function setAsyncActorKeys (actor: MActor) {
+function setAsyncActorKeys <T extends MActor> (actor: T) {
return createPrivateAndPublicKeys()
.then(({ publicKey, privateKey }) => {
actor.publicKey = publicKey
sharedInboxUrl: WEBSERVER.URL + '/inbox',
followersUrl: url + '/followers',
followingUrl: url + '/following'
- })
+ }) as MActor
}
async function updateActorInstance (actorInstance: ActorModel, attributes: ActivityPubActor) {
actorInstance.followingCount = followingCount
actorInstance.inboxUrl = attributes.inbox
actorInstance.outboxUrl = attributes.outbox
- actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
actorInstance.followersUrl = attributes.followers
actorInstance.followingUrl = attributes.following
+
+ if (attributes.endpoints && attributes.endpoints.sharedInbox) {
+ actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
+ }
}
type AvatarInfo = { name: string, onDisk: boolean, fileUrl: string }
})
if (actorCreated.type === 'Person' || actorCreated.type === 'Application') {
- actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountActorDefault
+ actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountDefault
actorCreated.Account.Actor = actorCreated
} else if (actorCreated.type === 'Group') { // Video channel
- actorCreated.VideoChannel = await saveVideoChannel(actorCreated, result, ownerActor, t) as MChannelActorAccountDefault
- actorCreated.VideoChannel.Actor = actorCreated
- actorCreated.VideoChannel.Account = ownerActor.Account
+ const channel = await saveVideoChannel(actorCreated, result, ownerActor, t)
+ actorCreated.VideoChannel = Object.assign(channel, { Actor: actorCreated, Account: ownerActor.Account })
}
actorCreated.Server = server
followingCount: followingCount,
inboxUrl: actorJSON.inbox,
outboxUrl: actorJSON.outbox,
- sharedInboxUrl: actorJSON.endpoints.sharedInbox,
followersUrl: actorJSON.followers,
- followingUrl: actorJSON.following
+ followingUrl: actorJSON.following,
+
+ sharedInboxUrl: actorJSON.endpoints && actorJSON.endpoints.sharedInbox
+ ? actorJSON.endpoints.sharedInbox
+ : null
})
const avatarInfo = await getAvatarInfoIfExists(actorJSON)