From 8424c4026afd7304880a4ce8138a04ffb3d8c938 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 30 Aug 2019 16:50:12 +0200 Subject: Add auto follow back support for instances --- server/models/account/account.ts | 2 +- server/models/account/user-notification-setting.ts | 12 +++++++++++- server/models/account/user-notification.ts | 19 +++++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 394a55f5e..ba1094536 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -381,7 +381,7 @@ export class AccountModel extends Model { } toActivityPubObject (this: MAccountAP) { - const obj = this.Actor.toActivityPubObject(this.name, 'Account') + const obj = this.Actor.toActivityPubObject(this.name) return Object.assign(obj, { summary: this.description diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts index 1506295cf..dc69a17fd 100644 --- a/server/models/account/user-notification-setting.ts +++ b/server/models/account/user-notification-setting.ts @@ -111,6 +111,15 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing') + ) + @Column + autoInstanceFollowing: UserNotificationSettingValue + @AllowNull(false) @Default(null) @Is( @@ -165,7 +174,8 @@ export class UserNotificationSettingModel extends Model { const account = this.Account ? this.formatActor(this.Account) : undefined + const actorFollowingType = { + Application: 'instance' as 'instance', + Group: 'channel' as 'channel', + Person: 'account' as 'account' + } const actorFollow = this.ActorFollow ? { id: this.ActorFollow.id, state: this.ActorFollow.state, @@ -415,9 +425,10 @@ export class UserNotificationModel extends Model { host: this.ActorFollow.ActorFollower.getHost() }, following: { - type: this.ActorFollow.ActorFollowing.VideoChannel ? 'channel' as 'channel' : 'account' as 'account', + type: actorFollowingType[this.ActorFollow.ActorFollowing.type], displayName: (this.ActorFollow.ActorFollowing.VideoChannel || this.ActorFollow.ActorFollowing.Account).getDisplayName(), - name: this.ActorFollow.ActorFollowing.preferredUsername + name: this.ActorFollow.ActorFollowing.preferredUsername, + host: this.ActorFollow.ActorFollowing.getHost() } } : undefined -- cgit v1.2.3