From 18e1efc7ecd3f5a6d774c16f17526d12ae46b2f5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 4 May 2021 21:15:57 +0900 Subject: Ad (#7495) * wip * Update ad.vue * Update default.widgets.vue * wip * Create 1620019354680-ad.ts * wip * Update ads.vue * wip * Update ad.vue --- src/models/entities/ad.ts | 53 +++++++++++++++++++++++++++++++++++++++++ src/models/index.ts | 2 ++ src/models/repositories/note.ts | 11 +-------- 3 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 src/models/entities/ad.ts (limited to 'src/models') diff --git a/src/models/entities/ad.ts b/src/models/entities/ad.ts new file mode 100644 index 0000000000..3279de29ea --- /dev/null +++ b/src/models/entities/ad.ts @@ -0,0 +1,53 @@ +import { Entity, Index, Column, PrimaryColumn } from 'typeorm'; +import { id } from '../id'; + +@Entity() +export class Ad { + @PrimaryColumn(id()) + public id: string; + + @Index() + @Column('timestamp with time zone', { + comment: 'The created date of the Ad.' + }) + public createdAt: Date; + + @Index() + @Column('timestamp with time zone', { + comment: 'The expired date of the Ad.' + }) + public expiresAt: Date; + + @Column('varchar', { + length: 32, nullable: false + }) + public place: string; + + @Column('varchar', { + length: 32, nullable: false + }) + public priority: string; + + @Column('varchar', { + length: 1024, nullable: false + }) + public url: string; + + @Column('varchar', { + length: 1024, nullable: false + }) + public imageUrl: string; + + @Column('varchar', { + length: 8192, nullable: false + }) + public memo: string; + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } +} diff --git a/src/models/index.ts b/src/models/index.ts index 6ce453ef33..9f8bd104e9 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -60,6 +60,7 @@ import { MutedNote } from './entities/muted-note'; import { ChannelFollowing } from './entities/channel-following'; import { ChannelNotePining } from './entities/channel-note-pining'; import { RegistryItem } from './entities/registry-item'; +import { Ad } from './entities/ad'; import { PasswordResetRequest } from './entities/password-reset-request'; export const Announcements = getRepository(Announcement); @@ -123,4 +124,5 @@ export const Channels = getCustomRepository(ChannelRepository); export const ChannelFollowings = getRepository(ChannelFollowing); export const ChannelNotePinings = getRepository(ChannelNotePining); export const RegistryItems = getRepository(RegistryItem); +export const Ads = getRepository(Ad); export const PasswordResetRequests = getRepository(PasswordResetRequest); diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index cdf4841918..7b1df73024 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -200,8 +200,6 @@ export class NoteRepository extends Repository { mentions: note.mentions.length > 0 ? note.mentions : undefined, uri: note.uri || undefined, url: note.url || undefined, - _featuredId_: (note as any)._featuredId_ || undefined, - _prId_: (note as any)._prId_ || undefined, ...(opts.detail ? { reply: note.replyId ? this.pack(note.reply || note.replyId, me, { @@ -448,14 +446,7 @@ export const packedNoteSchema = { optional: false as const, nullable: true as const, description: 'The human readable url of a note. it will be null when the note is local.', }, - _featuredId_: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, - _prId_: { - type: 'string' as const, - optional: false as const, nullable: true as const, - }, + myReaction: { type: 'object' as const, optional: true as const, nullable: true as const, -- cgit v1.2.3-freya