X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Factivitypub%2Factor.ts;h=e16bd5d7943de0b36e55cba50e56c64ea58e7516;hb=aa55a4da422330fe2816f1764b64f6607a0ca4aa;hp=35d7c35e8635bcba7c3c1e3f20b8c05f4cbe5303;hpb=9a12f169c15b638fe78cf6e85a1993550a25e404;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 35d7c35e8..e16bd5d79 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -42,6 +42,17 @@ enum ScopeNames { FULL = 'FULL' } +export const unusedActorAttributesForAPI = [ + 'publicKey', + 'privateKey', + 'inboxUrl', + 'outboxUrl', + 'sharedInboxUrl', + 'followersUrl', + 'followingUrl', + 'url' +] + @DefaultScope({ include: [ { @@ -260,12 +271,13 @@ export class ActorModel extends Model { return ActorModel.scope(ScopeNames.FULL).findAll(query) } - static loadLocalByName (preferredUsername: string) { + static loadLocalByName (preferredUsername: string, transaction?: Sequelize.Transaction) { const query = { where: { preferredUsername, serverId: null - } + }, + transaction } return ActorModel.scope(ScopeNames.FULL).findOne(query) @@ -311,45 +323,6 @@ export class ActorModel extends Model { }) } - static async getActorsFollowerSharedInboxUrls (actors: ActorModel[], t: Sequelize.Transaction) { - const query = { - // attribute: [], - where: { - id: { - [Sequelize.Op.in]: actors.map(a => a.id) - } - }, - include: [ - { - // attributes: [ ], - model: ActorFollowModel.unscoped(), - required: true, - as: 'ActorFollowers', - where: { - state: 'accepted' - }, - include: [ - { - attributes: [ 'sharedInboxUrl' ], - model: ActorModel.unscoped(), - as: 'ActorFollower', - required: true - } - ] - } - ], - transaction: t - } - - const hash: { [ id: number ]: string[] } = {} - const res = await ActorModel.findAll(query) - for (const actor of res) { - hash[actor.id] = actor.ActorFollowers.map(follow => follow.ActorFollower.sharedInboxUrl) - } - - return hash - } - toFormattedJSON () { let avatar: Avatar = null if (this.Avatar) {