aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/account.ts1
-rw-r--r--server/models/account/user.ts4
-rw-r--r--server/models/activitypub/actor.ts16
-rw-r--r--server/models/video/video-channel.ts8
-rw-r--r--server/models/video/video.ts7
5 files changed, 23 insertions, 13 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 312451abe..d33353af7 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -411,7 +411,6 @@ export class AccountModel extends Model {
411 id: this.id, 411 id: this.id,
412 displayName: this.getDisplayName(), 412 displayName: this.getDisplayName(),
413 description: this.description, 413 description: this.description,
414 createdAt: this.createdAt,
415 updatedAt: this.updatedAt, 414 updatedAt: this.updatedAt,
416 userId: this.userId ? this.userId : undefined 415 userId: this.userId ? this.userId : undefined
417 } 416 }
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 00c6d73aa..513455773 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -565,6 +565,10 @@ export class UserModel extends Model {
565 return UserModel.unscoped().findByPk(id) 565 return UserModel.unscoped().findByPk(id)
566 } 566 }
567 567
568 static loadByIdFull (id: number): Promise<MUserDefault> {
569 return UserModel.findByPk(id)
570 }
571
568 static loadByIdWithChannels (id: number, withStats = false): Promise<MUserDefault> { 572 static loadByIdWithChannels (id: number, withStats = false): Promise<MUserDefault> {
569 const scopes = [ 573 const scopes = [
570 ScopeNames.WITH_VIDEOCHANNELS 574 ScopeNames.WITH_VIDEOCHANNELS
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 19f3f7e04..1af9efac2 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -69,9 +69,7 @@ export const unusedActorAttributesForAPI = [
69 'outboxUrl', 69 'outboxUrl',
70 'sharedInboxUrl', 70 'sharedInboxUrl',
71 'followersUrl', 71 'followersUrl',
72 'followingUrl', 72 'followingUrl'
73 'createdAt',
74 'updatedAt'
75] 73]
76 74
77@DefaultScope(() => ({ 75@DefaultScope(() => ({
@@ -222,6 +220,10 @@ export class ActorModel extends Model {
222 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max)) 220 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
223 followingUrl: string 221 followingUrl: string
224 222
223 @AllowNull(true)
224 @Column
225 remoteCreatedAt: Date
226
225 @CreatedAt 227 @CreatedAt
226 createdAt: Date 228 createdAt: Date
227 229
@@ -555,8 +557,7 @@ export class ActorModel extends Model {
555 followingCount: this.followingCount, 557 followingCount: this.followingCount,
556 followersCount: this.followersCount, 558 followersCount: this.followersCount,
557 banner, 559 banner,
558 createdAt: this.createdAt, 560 createdAt: this.getCreatedAt()
559 updatedAt: this.updatedAt
560 }) 561 })
561 } 562 }
562 563
@@ -608,6 +609,7 @@ export class ActorModel extends Model {
608 owner: this.url, 609 owner: this.url,
609 publicKeyPem: this.publicKey 610 publicKeyPem: this.publicKey
610 }, 611 },
612 published: this.getCreatedAt().toISOString(),
611 icon, 613 icon,
612 image 614 image
613 } 615 }
@@ -690,4 +692,8 @@ export class ActorModel extends Model {
690 692
691 return isOutdated(this, ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL) 693 return isOutdated(this, ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL)
692 } 694 }
695
696 getCreatedAt (this: MActorAPChannel | MActorAPAccount | MActorFormattable) {
697 return this.remoteCreatedAt || this.createdAt
698 }
693} 699}
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index b7ffbd3b1..081b21f2d 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -1,4 +1,4 @@
1import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions } from 'sequelize' 1import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions, Transaction } from 'sequelize'
2import { 2import {
3 AllowNull, 3 AllowNull,
4 BeforeDestroy, 4 BeforeDestroy,
@@ -17,6 +17,7 @@ import {
17 Table, 17 Table,
18 UpdatedAt 18 UpdatedAt
19} from 'sequelize-typescript' 19} from 'sequelize-typescript'
20import { setAsUpdated } from '@server/helpers/database-utils'
20import { MAccountActor } from '@server/types/models' 21import { MAccountActor } from '@server/types/models'
21import { ActivityPubActor } from '../../../shared/models/activitypub' 22import { ActivityPubActor } from '../../../shared/models/activitypub'
22import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos' 23import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos'
@@ -653,7 +654,6 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
653 description: this.description, 654 description: this.description,
654 support: this.support, 655 support: this.support,
655 isLocal: this.Actor.isOwned(), 656 isLocal: this.Actor.isOwned(),
656 createdAt: this.createdAt,
657 updatedAt: this.updatedAt, 657 updatedAt: this.updatedAt,
658 ownerAccount: undefined, 658 ownerAccount: undefined,
659 videosCount, 659 videosCount,
@@ -691,4 +691,8 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
691 isOutdated () { 691 isOutdated () {
692 return this.Actor.isOutdated() 692 return this.Actor.isOutdated()
693 } 693 }
694
695 setAsUpdated (transaction: Transaction) {
696 return setAsUpdated('videoChannel', this.id, transaction)
697 }
694} 698}
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index e55a21a6b..8c316e00c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -24,6 +24,7 @@ import {
24 Table, 24 Table,
25 UpdatedAt 25 UpdatedAt
26} from 'sequelize-typescript' 26} from 'sequelize-typescript'
27import { setAsUpdated } from '@server/helpers/database-utils'
27import { buildNSFWFilter } from '@server/helpers/express-utils' 28import { buildNSFWFilter } from '@server/helpers/express-utils'
28import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 29import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
29import { LiveManager } from '@server/lib/live-manager' 30import { LiveManager } from '@server/lib/live-manager'
@@ -2053,11 +2054,7 @@ export class VideoModel extends Model {
2053 } 2054 }
2054 2055
2055 setAsRefreshed () { 2056 setAsRefreshed () {
2056 const options = { 2057 return setAsUpdated('video', this.id)
2057 where: { id: this.id }
2058 }
2059
2060 return VideoModel.update({ updatedAt: new Date() }, options)
2061 } 2058 }
2062 2059
2063 requiresAuth () { 2060 requiresAuth () {