@@ -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, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js';
|
||||
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, 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, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js';
|
||||
import type { DataSource } from 'typeorm';
|
||||
import type { Provider } from '@nestjs/common';
|
||||
|
||||
@@ -172,12 +172,6 @@ const $driveFoldersRepository: Provider = {
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $notificationsRepository: Provider = {
|
||||
provide: DI.notificationsRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(Notification),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $metasRepository: Provider = {
|
||||
provide: DI.metasRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(Meta),
|
||||
@@ -426,7 +420,6 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$emojisRepository,
|
||||
$driveFilesRepository,
|
||||
$driveFoldersRepository,
|
||||
$notificationsRepository,
|
||||
$metasRepository,
|
||||
$mutingsRepository,
|
||||
$renoteMutingsRepository,
|
||||
@@ -493,7 +486,6 @@ const $roleAssignmentsRepository: Provider = {
|
||||
$emojisRepository,
|
||||
$driveFilesRepository,
|
||||
$driveFoldersRepository,
|
||||
$notificationsRepository,
|
||||
$metasRepository,
|
||||
$mutingsRepository,
|
||||
$renoteMutingsRepository,
|
||||
|
@@ -1,54 +1,19 @@
|
||||
import { Entity, Index, JoinColumn, ManyToOne, Column, PrimaryColumn } from 'typeorm';
|
||||
import { notificationTypes, obsoleteNotificationTypes } from '@/types.js';
|
||||
import { id } from '../id.js';
|
||||
import { notificationTypes } from '@/types.js';
|
||||
import { User } from './User.js';
|
||||
import { Note } from './Note.js';
|
||||
import { FollowRequest } from './FollowRequest.js';
|
||||
import { AccessToken } from './AccessToken.js';
|
||||
|
||||
@Entity()
|
||||
export class Notification {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
export type Notification = {
|
||||
id: string;
|
||||
|
||||
@Index()
|
||||
@Column('timestamp with time zone', {
|
||||
comment: 'The created date of the Notification.',
|
||||
})
|
||||
public createdAt: Date;
|
||||
|
||||
/**
|
||||
* 通知の受信者
|
||||
*/
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'The ID of recipient user of the Notification.',
|
||||
})
|
||||
public notifieeId: User['id'];
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public notifiee: User | null;
|
||||
// RedisのためDateではなくstring
|
||||
createdAt: string;
|
||||
|
||||
/**
|
||||
* 通知の送信者(initiator)
|
||||
*/
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
comment: 'The ID of sender user of the Notification.',
|
||||
})
|
||||
public notifierId: User['id'] | null;
|
||||
|
||||
@ManyToOne(type => User, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public notifier: User | null;
|
||||
notifierId: User['id'] | null;
|
||||
|
||||
/**
|
||||
* 通知の種類。
|
||||
@@ -64,104 +29,37 @@ export class Notification {
|
||||
* achievementEarned - 実績を獲得
|
||||
* app - アプリ通知
|
||||
*/
|
||||
@Index()
|
||||
@Column('enum', {
|
||||
enum: [
|
||||
...notificationTypes,
|
||||
...obsoleteNotificationTypes,
|
||||
],
|
||||
comment: 'The type of the Notification.',
|
||||
})
|
||||
public type: typeof notificationTypes[number];
|
||||
type: typeof notificationTypes[number];
|
||||
|
||||
/**
|
||||
* 通知が読まれたかどうか
|
||||
*/
|
||||
@Index()
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
comment: 'Whether the Notification is read.',
|
||||
})
|
||||
public isRead: boolean;
|
||||
noteId: Note['id'] | null;
|
||||
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
})
|
||||
public noteId: Note['id'] | null;
|
||||
followRequestId: FollowRequest['id'] | null;
|
||||
|
||||
@ManyToOne(type => Note, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public note: Note | null;
|
||||
reaction: string | null;
|
||||
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
})
|
||||
public followRequestId: FollowRequest['id'] | null;
|
||||
choice: number | null;
|
||||
|
||||
@ManyToOne(type => FollowRequest, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public followRequest: FollowRequest | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 128, nullable: true,
|
||||
})
|
||||
public reaction: string | null;
|
||||
|
||||
@Column('integer', {
|
||||
nullable: true,
|
||||
})
|
||||
public choice: number | null;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 128, nullable: true,
|
||||
})
|
||||
public achievement: string | null;
|
||||
achievement: string | null;
|
||||
|
||||
/**
|
||||
* アプリ通知のbody
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 2048, nullable: true,
|
||||
})
|
||||
public customBody: string | null;
|
||||
customBody: string | null;
|
||||
|
||||
/**
|
||||
* アプリ通知のheader
|
||||
* (省略時はアプリ名で表示されることを期待)
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 256, nullable: true,
|
||||
})
|
||||
public customHeader: string | null;
|
||||
customHeader: string | null;
|
||||
|
||||
/**
|
||||
* アプリ通知のicon(URL)
|
||||
* (省略時はアプリアイコンで表示されることを期待)
|
||||
*/
|
||||
@Column('varchar', {
|
||||
length: 1024, nullable: true,
|
||||
})
|
||||
public customIcon: string | null;
|
||||
customIcon: string | null;
|
||||
|
||||
/**
|
||||
* アプリ通知のアプリ(のトークン)
|
||||
*/
|
||||
@Index()
|
||||
@Column({
|
||||
...id(),
|
||||
nullable: true,
|
||||
})
|
||||
public appAccessTokenId: AccessToken['id'] | null;
|
||||
|
||||
@ManyToOne(type => AccessToken, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
public appAccessToken: AccessToken | null;
|
||||
appAccessTokenId: AccessToken['id'] | null;
|
||||
}
|
||||
|
@@ -32,7 +32,6 @@ import { NoteFavorite } from '@/models/entities/NoteFavorite.js';
|
||||
import { NoteReaction } from '@/models/entities/NoteReaction.js';
|
||||
import { NoteThreadMuting } from '@/models/entities/NoteThreadMuting.js';
|
||||
import { NoteUnread } from '@/models/entities/NoteUnread.js';
|
||||
import { Notification } from '@/models/entities/Notification.js';
|
||||
import { Page } from '@/models/entities/Page.js';
|
||||
import { PageLike } from '@/models/entities/PageLike.js';
|
||||
import { PasswordResetRequest } from '@/models/entities/PasswordResetRequest.js';
|
||||
@@ -100,7 +99,6 @@ export {
|
||||
NoteReaction,
|
||||
NoteThreadMuting,
|
||||
NoteUnread,
|
||||
Notification,
|
||||
Page,
|
||||
PageLike,
|
||||
PasswordResetRequest,
|
||||
@@ -167,7 +165,6 @@ export type NoteFavoritesRepository = Repository<NoteFavorite>;
|
||||
export type NoteReactionsRepository = Repository<NoteReaction>;
|
||||
export type NoteThreadMutingsRepository = Repository<NoteThreadMuting>;
|
||||
export type NoteUnreadsRepository = Repository<NoteUnread>;
|
||||
export type NotificationsRepository = Repository<Notification>;
|
||||
export type PagesRepository = Repository<Page>;
|
||||
export type PageLikesRepository = Repository<PageLike>;
|
||||
export type PasswordResetRequestsRepository = Repository<PasswordResetRequest>;
|
||||
|
@@ -14,10 +14,6 @@ export const packedNotificationSchema = {
|
||||
optional: false, nullable: false,
|
||||
format: 'date-time',
|
||||
},
|
||||
isRead: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
|
Reference in New Issue
Block a user