diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/account/account.ts | 2 | ||||
-rw-r--r-- | server/models/account/user-notification-setting.ts | 12 | ||||
-rw-r--r-- | server/models/account/user-notification.ts | 19 | ||||
-rw-r--r-- | server/models/activitypub/actor.ts | 12 | ||||
-rw-r--r-- | server/models/server/server.ts | 10 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 2 |
6 files changed, 40 insertions, 17 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 | ||
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 67a1b5bc1..05de1905d 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts | |||
@@ -43,7 +43,6 @@ import { | |||
43 | MActorFormattable, | 43 | MActorFormattable, |
44 | MActorFull, | 44 | MActorFull, |
45 | MActorHost, | 45 | MActorHost, |
46 | MActorRedundancyAllowedOpt, | ||
47 | MActorServer, | 46 | MActorServer, |
48 | MActorSummaryFormattable | 47 | MActorSummaryFormattable |
49 | } from '../../typings/models' | 48 | } from '../../typings/models' |
@@ -430,15 +429,8 @@ export class ActorModel extends Model<ActorModel> { | |||
430 | }) | 429 | }) |
431 | } | 430 | } |
432 | 431 | ||
433 | toActivityPubObject (this: MActorAP, name: string, type: 'Account' | 'Application' | 'VideoChannel') { | 432 | toActivityPubObject (this: MActorAP, name: string) { |
434 | let activityPubType | 433 | let activityPubType |
435 | if (type === 'Account') { | ||
436 | activityPubType = 'Person' as 'Person' | ||
437 | } else if (type === 'Application') { | ||
438 | activityPubType = 'Application' as 'Application' | ||
439 | } else { // VideoChannel | ||
440 | activityPubType = 'Group' as 'Group' | ||
441 | } | ||
442 | 434 | ||
443 | let icon = undefined | 435 | let icon = undefined |
444 | if (this.avatarId) { | 436 | if (this.avatarId) { |
@@ -451,7 +443,7 @@ export class ActorModel extends Model<ActorModel> { | |||
451 | } | 443 | } |
452 | 444 | ||
453 | const json = { | 445 | const json = { |
454 | type: activityPubType, | 446 | type: this.type, |
455 | id: this.url, | 447 | id: this.url, |
456 | following: this.getFollowingUrl(), | 448 | following: this.getFollowingUrl(), |
457 | followers: this.getFollowersUrl(), | 449 | followers: this.getFollowersUrl(), |
diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 3b6759b5c..8b07115f1 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts | |||
@@ -51,6 +51,16 @@ export class ServerModel extends Model<ServerModel> { | |||
51 | }) | 51 | }) |
52 | BlockedByAccounts: ServerBlocklistModel[] | 52 | BlockedByAccounts: ServerBlocklistModel[] |
53 | 53 | ||
54 | static load (id: number): Bluebird<MServer> { | ||
55 | const query = { | ||
56 | where: { | ||
57 | id | ||
58 | } | ||
59 | } | ||
60 | |||
61 | return ServerModel.findOne(query) | ||
62 | } | ||
63 | |||
54 | static loadByHost (host: string): Bluebird<MServer> { | 64 | static loadByHost (host: string): Bluebird<MServer> { |
55 | const query = { | 65 | const query = { |
56 | where: { | 66 | where: { |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 7178631b4..05545bd9d 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -517,7 +517,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
517 | } | 517 | } |
518 | 518 | ||
519 | toActivityPubObject (this: MChannelAP): ActivityPubActor { | 519 | toActivityPubObject (this: MChannelAP): ActivityPubActor { |
520 | const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel') | 520 | const obj = this.Actor.toActivityPubObject(this.name) |
521 | 521 | ||
522 | return Object.assign(obj, { | 522 | return Object.assign(obj, { |
523 | summary: this.description, | 523 | summary: this.description, |