
* chore: 著作権とライセンスについての情報を各ファイルに追加する * chore: Add the SPDX information to each file Add copyright and licensing information as defined in version 3.0 of the REUSE Specification. * tweak format --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * chore: Add SPDX-License-Identifier [skip ci] * add missing SPDX-License-Identifier * remove unused file --------- Co-authored-by: Shun Sakai <sorairolake@protonmail.ch> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import type { AdsRepository } from '@/models/index.js';
|
|
import { IdService } from '@/core/IdService.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
|
|
export const meta = {
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true,
|
|
requireModerator: true,
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
url: { type: 'string', minLength: 1 },
|
|
memo: { type: 'string' },
|
|
place: { type: 'string' },
|
|
priority: { type: 'string' },
|
|
ratio: { type: 'integer' },
|
|
expiresAt: { type: 'integer' },
|
|
startsAt: { type: 'integer' },
|
|
imageUrl: { type: 'string', minLength: 1 },
|
|
dayOfWeek: { type: 'integer' },
|
|
},
|
|
required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'startsAt', 'imageUrl', 'dayOfWeek'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
constructor(
|
|
@Inject(DI.adsRepository)
|
|
private adsRepository: AdsRepository,
|
|
|
|
private idService: IdService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
await this.adsRepository.insert({
|
|
id: this.idService.genId(),
|
|
createdAt: new Date(),
|
|
expiresAt: new Date(ps.expiresAt),
|
|
startsAt: new Date(ps.startsAt),
|
|
dayOfWeek: ps.dayOfWeek,
|
|
url: ps.url,
|
|
imageUrl: ps.imageUrl,
|
|
priority: ps.priority,
|
|
ratio: ps.ratio,
|
|
place: ps.place,
|
|
memo: ps.memo,
|
|
});
|
|
});
|
|
}
|
|
}
|