* wip

* wip

* wip

* wip

* wip

* Update define.ts

* Update update.ts

* Update user.ts

* wip

* wip

* Update request.ts

* URL

* wip

* wip

* wip

* wip

* Update invite.ts

* Update create.ts
This commit is contained in:
syuilo 2021-03-24 11:05:37 +09:00 committed by GitHub
parent 62cc14c93b
commit ce340aba7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 252 additions and 201 deletions

View file

@ -38,14 +38,14 @@ import { getAntennas } from '@/misc/antenna-cache';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
class NotificationManager {
private notifier: User;
private notifier: { id: User['id']; };
private note: Note;
private queue: {
target: ILocalUser['id'];
reason: NotificationType;
}[];
constructor(notifier: User, note: Note) {
constructor(notifier: { id: User['id']; }, note: Note) {
this.notifier = notifier;
this.note = note;
this.queue = [];
@ -112,7 +112,7 @@ type Option = {
app?: App | null;
};
export default async (user: User, data: Option, silent = false) => new Promise<Note>(async (res, rej) => {
export default async (user: { id: User['id']; username: User['username']; host: User['host']; isSilenced: User['isSilenced']; }, data: Option, silent = false) => new Promise<Note>(async (res, rej) => {
// チャンネル外にリプライしたら対象のスコープに合わせる
// (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで)
if (data.reply && data.channel && data.reply.channelId !== data.channel.id) {
@ -420,7 +420,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
// この処理が行われるのはノート作成後なので、ノートが一つしかなかったら最初の投稿だと判断できる
// TODO: とはいえノートを削除して何回も投稿すればその分だけインクリメントされる雑さもあるのでどうにかしたい
if (count === 1) {
Channels.increment({ id: data.channel.id }, 'usersCount', 1);
Channels.increment({ id: data.channel!.id }, 'usersCount', 1);
}
});
}
@ -449,7 +449,7 @@ function incRenoteCount(renote: Note) {
.execute();
}
async function insertNote(user: User, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) {
async function insertNote(user: { id: User['id']; host: User['host']; }, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) {
const insert = new Note({
id: genId(data.createdAt!),
createdAt: data.createdAt!,
@ -555,7 +555,7 @@ function index(note: Note) {
});
}
async function notifyToWatchersOfRenotee(renote: Note, user: User, nm: NotificationManager, type: NotificationType) {
async function notifyToWatchersOfRenotee(renote: Note, user: { id: User['id']; }, nm: NotificationManager, type: NotificationType) {
const watchers = await NoteWatchings.find({
noteId: renote.id,
userId: Not(user.id)
@ -566,7 +566,7 @@ async function notifyToWatchersOfRenotee(renote: Note, user: User, nm: Notificat
}
}
async function notifyToWatchersOfReplyee(reply: Note, user: User, nm: NotificationManager) {
async function notifyToWatchersOfReplyee(reply: Note, user: { id: User['id']; }, nm: NotificationManager) {
const watchers = await NoteWatchings.find({
noteId: reply.id,
userId: Not(user.id)
@ -594,7 +594,7 @@ function saveReply(reply: Note, note: Note) {
Notes.increment({ id: reply.id }, 'repliesCount', 1);
}
function incNotesCountOfUser(user: User) {
function incNotesCountOfUser(user: { id: User['id']; }) {
Users.createQueryBuilder().update()
.set({
updatedAt: new Date(),
@ -604,7 +604,7 @@ function incNotesCountOfUser(user: User) {
.execute();
}
async function extractMentionedUsers(user: User, tokens: ReturnType<typeof parse>): Promise<User[]> {
async function extractMentionedUsers(user: { host: User['host']; }, tokens: ReturnType<typeof parse>): Promise<User[]> {
if (tokens == null) return [];
const mentions = extractMentions(tokens);