aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/user-notification.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-30 16:50:12 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-09-04 16:24:58 +0200
commit8424c4026afd7304880a4ce8138a04ffb3d8c938 (patch)
tree5b42625a59307b03333aa7d293b40b4c90da8f73 /server/models/account/user-notification.ts
parentf69ec5f340638ef577e8f5b9b1fb844778656a1f (diff)
downloadPeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.tar.gz
PeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.tar.zst
PeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.zip
Add auto follow back support for instances
Diffstat (limited to 'server/models/account/user-notification.ts')
-rw-r--r--server/models/account/user-notification.ts19
1 files changed, 15 insertions, 4 deletions
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