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/server/api/endpoints/meta.ts | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/server/api/endpoints/meta.ts') diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 3760c8b37b..5b7292ef16 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -2,8 +2,9 @@ import $ from 'cafy'; import config from '@/config'; import define from '../define'; import { fetchMeta } from '@/misc/fetch-meta'; -import { Emojis, Users } from '../../../models'; +import { Ads, Emojis, Users } from '../../../models'; import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits'; +import { MoreThan } from 'typeorm'; export const meta = { desc: { @@ -193,6 +194,30 @@ export const meta = { } } }, + ads: { + type: 'array' as const, + optional: false as const, nullable: false as const, + items: { + type: 'object' as const, + optional: false as const, nullable: false as const, + properties: { + place: { + type: 'string' as const, + optional: false as const, nullable: false as const + }, + url: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'url' + }, + imageUrl: { + type: 'string' as const, + optional: false as const, nullable: false as const, + format: 'url' + }, + } + } + }, requireSetup: { type: 'boolean' as const, optional: false as const, nullable: false as const, @@ -443,6 +468,12 @@ export default define(meta, async (ps, me) => { } }); + const ads = await Ads.find({ + where: { + expiresAt: MoreThan(new Date()) + }, + }); + const response: any = { maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, @@ -477,6 +508,12 @@ export default define(meta, async (ps, me) => { logoImageUrl: instance.logoImageUrl, maxNoteTextLength: Math.min(instance.maxNoteTextLength, DB_MAX_NOTE_TEXT_LENGTH), emojis: await Emojis.packMany(emojis), + ads: ads.map(ad => ({ + url: ad.url, + place: ad.place, + priority: ad.priority, + imageUrl: ad.imageUrl, + })), enableEmail: instance.enableEmail, enableTwitterIntegration: instance.enableTwitterIntegration, -- cgit v1.2.3-freya