aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account.ts2
-rw-r--r--server/models/account/user-notification-setting.ts12
-rw-r--r--server/models/account/user-notification.ts19
3 files changed, 27 insertions, 6 deletions
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<AccountModel> {
381 } 381 }
382 382
383 toActivityPubObject (this: MAccountAP) { 383 toActivityPubObject (this: MAccountAP) {
384 const obj = this.Actor.toActivityPubObject(this.name, 'Account') 384 const obj = this.Actor.toActivityPubObject(this.name)
385 385
386 return Object.assign(obj, { 386 return Object.assign(obj, {
387 summary: this.description 387 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
@@ -114,6 +114,15 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
114 @AllowNull(false) 114 @AllowNull(false)
115 @Default(null) 115 @Default(null)
116 @Is( 116 @Is(
117 'UserNotificationSettingNewInstanceFollower',
118 value => throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing')
119 )
120 @Column
121 autoInstanceFollowing: UserNotificationSettingValue
122
123 @AllowNull(false)
124 @Default(null)
125 @Is(
117 'UserNotificationSettingNewFollow', 126 'UserNotificationSettingNewFollow',
118 value => throwIfNotValid(value, isUserNotificationSettingValid, 'newFollow') 127 value => throwIfNotValid(value, isUserNotificationSettingValid, 'newFollow')
119 ) 128 )
@@ -165,7 +174,8 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
165 newUserRegistration: this.newUserRegistration, 174 newUserRegistration: this.newUserRegistration,
166 commentMention: this.commentMention, 175 commentMention: this.commentMention,
167 newFollow: this.newFollow, 176 newFollow: this.newFollow,
168 newInstanceFollower: this.newInstanceFollower 177 newInstanceFollower: this.newInstanceFollower,
178 autoInstanceFollowing: this.autoInstanceFollowing
169 } 179 }
170 } 180 }
171} 181}
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts
index 9b13a8376..ccb81b891 100644
--- a/server/models/account/user-notification.ts
+++ b/server/models/account/user-notification.ts
@@ -135,13 +135,18 @@ function buildAccountInclude (required: boolean, withActor = false) {
135 ] 135 ]
136 }, 136 },
137 { 137 {
138 attributes: [ 'preferredUsername' ], 138 attributes: [ 'preferredUsername', 'type' ],
139 model: ActorModel.unscoped(), 139 model: ActorModel.unscoped(),
140 required: true, 140 required: true,
141 as: 'ActorFollowing', 141 as: 'ActorFollowing',
142 include: [ 142 include: [
143 buildChannelInclude(false), 143 buildChannelInclude(false),
144 buildAccountInclude(false) 144 buildAccountInclude(false),
145 {
146 attributes: [ 'host' ],
147 model: ServerModel.unscoped(),
148 required: false
149 }
145 ] 150 ]
146 } 151 }
147 ] 152 ]
@@ -404,6 +409,11 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
404 409
405 const account = this.Account ? this.formatActor(this.Account) : undefined 410 const account = this.Account ? this.formatActor(this.Account) : undefined
406 411
412 const actorFollowingType = {
413 Application: 'instance' as 'instance',
414 Group: 'channel' as 'channel',
415 Person: 'account' as 'account'
416 }
407 const actorFollow = this.ActorFollow ? { 417 const actorFollow = this.ActorFollow ? {
408 id: this.ActorFollow.id, 418 id: this.ActorFollow.id,
409 state: this.ActorFollow.state, 419 state: this.ActorFollow.state,
@@ -415,9 +425,10 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
415 host: this.ActorFollow.ActorFollower.getHost() 425 host: this.ActorFollow.ActorFollower.getHost()
416 }, 426 },
417 following: { 427 following: {
418 type: this.ActorFollow.ActorFollowing.VideoChannel ? 'channel' as 'channel' : 'account' as 'account', 428 type: actorFollowingType[this.ActorFollow.ActorFollowing.type],
419 displayName: (this.ActorFollow.ActorFollowing.VideoChannel || this.ActorFollow.ActorFollowing.Account).getDisplayName(), 429 displayName: (this.ActorFollow.ActorFollowing.VideoChannel || this.ActorFollow.ActorFollowing.Account).getDisplayName(),
420 name: this.ActorFollow.ActorFollowing.preferredUsername 430 name: this.ActorFollow.ActorFollowing.preferredUsername,
431 host: this.ActorFollow.ActorFollowing.getHost()
421 } 432 }
422 } : undefined 433 } : undefined
423 434