@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelNotePining, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js';
|
||||
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, ChannelNotePining, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js';
|
||||
import type { DataSource } from 'typeorm';
|
||||
import type { Provider } from '@nestjs/common';
|
||||
|
||||
@@ -340,6 +340,12 @@ const $channelFollowingsRepository: Provider = {
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $channelFavoritesRepository: Provider = {
|
||||
provide: DI.channelFavoritesRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(ChannelFavorite),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $channelNotePiningsRepository: Provider = {
|
||||
provide: DI.channelNotePiningsRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(ChannelNotePining),
|
||||
@@ -460,6 +466,7 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$mutedNotesRepository,
|
||||
$channelsRepository,
|
||||
$channelFollowingsRepository,
|
||||
$channelFavoritesRepository,
|
||||
$channelNotePiningsRepository,
|
||||
$registryItemsRepository,
|
||||
$webhooksRepository,
|
||||
@@ -528,6 +535,7 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$mutedNotesRepository,
|
||||
$channelsRepository,
|
||||
$channelFollowingsRepository,
|
||||
$channelFavoritesRepository,
|
||||
$channelNotePiningsRepository,
|
||||
$registryItemsRepository,
|
||||
$webhooksRepository,
|
||||
|
41
packages/backend/src/models/entities/ChannelFavorite.ts
Normal file
41
packages/backend/src/models/entities/ChannelFavorite.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { id } from '../id.js';
|
||||
import { User } from './User.js';
|
||||
import { Channel } from './Channel.js';
|
||||
|
||||
@Entity()
|
||||
@Index(['userId', 'channelId'], { unique: true })
|
||||
export class ChannelFavorite {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
||||
@Index()
|
||||
@Column('timestamp with time zone', {
|
||||
comment: 'The created date of the ChannelFavorite.',
|
||||
})
|
||||
public createdAt: Date;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
})
|
||||
public channelId: Channel['id'];
|
||||
|
||||
@ManyToOne(type => Channel, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public channel: Channel | null;
|
||||
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
})
|
||||
public userId: User['id'];
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public user: User | null;
|
||||
}
|
@@ -10,6 +10,7 @@ import { AttestationChallenge } from '@/models/entities/AttestationChallenge.js'
|
||||
import { AuthSession } from '@/models/entities/AuthSession.js';
|
||||
import { Blocking } from '@/models/entities/Blocking.js';
|
||||
import { ChannelFollowing } from '@/models/entities/ChannelFollowing.js';
|
||||
import { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
|
||||
import { ChannelNotePining } from '@/models/entities/ChannelNotePining.js';
|
||||
import { Clip } from '@/models/entities/Clip.js';
|
||||
import { ClipNote } from '@/models/entities/ClipNote.js';
|
||||
@@ -79,6 +80,7 @@ export {
|
||||
AuthSession,
|
||||
Blocking,
|
||||
ChannelFollowing,
|
||||
ChannelFavorite,
|
||||
ChannelNotePining,
|
||||
Clip,
|
||||
ClipNote,
|
||||
@@ -147,6 +149,7 @@ export type AttestationChallengesRepository = Repository<AttestationChallenge>;
|
||||
export type AuthSessionsRepository = Repository<AuthSession>;
|
||||
export type BlockingsRepository = Repository<Blocking>;
|
||||
export type ChannelFollowingsRepository = Repository<ChannelFollowing>;
|
||||
export type ChannelFavoritesRepository = Repository<ChannelFavorite>;
|
||||
export type ChannelNotePiningsRepository = Repository<ChannelNotePining>;
|
||||
export type ClipsRepository = Repository<Clip>;
|
||||
export type ClipNotesRepository = Repository<ClipNote>;
|
||||
|
@@ -42,6 +42,10 @@ export const packedChannelSchema = {
|
||||
type: 'boolean',
|
||||
optional: true, nullable: false,
|
||||
},
|
||||
isFavorited: {
|
||||
type: 'boolean',
|
||||
optional: true, nullable: false,
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
|
Reference in New Issue
Block a user