summaryrefslogtreecommitdiff
path: root/src/services/note
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-03-24 11:05:37 +0900
committerGitHub <noreply@github.com>2021-03-24 11:05:37 +0900
commitce340aba7a37394c70b9f3d7cece9cfa5e91d94c (patch)
tree99612ea0d039f20e0baa9ca243e8cec0af96b11a /src/services/note
parentfix bug (diff)
downloadsharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.tar.gz
sharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.tar.bz2
sharkey-ce340aba7a37394c70b9f3d7cece9cfa5e91d94c.zip
Refactor (#7394)
* 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
Diffstat (limited to 'src/services/note')
-rw-r--r--src/services/note/create.ts18
-rw-r--r--src/services/note/reaction/create.ts2
-rw-r--r--src/services/note/reaction/delete.ts2
3 files changed, 11 insertions, 11 deletions
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 23ccf9042d..64d5513ecc 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -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);
diff --git a/src/services/note/reaction/create.ts b/src/services/note/reaction/create.ts
index 952927f192..e2e7fc54ef 100644
--- a/src/services/note/reaction/create.ts
+++ b/src/services/note/reaction/create.ts
@@ -14,7 +14,7 @@ import deleteReaction from './delete';
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error';
import { NoteReaction } from '../../../models/entities/note-reaction';
-export default async (user: User, note: Note, reaction?: string) => {
+export default async (user: { id: User['id']; host: User['host']; }, note: Note, reaction?: string) => {
// TODO: cache
reaction = await toDbReaction(reaction, user.host);
diff --git a/src/services/note/reaction/delete.ts b/src/services/note/reaction/delete.ts
index c0787eee70..712031fa88 100644
--- a/src/services/note/reaction/delete.ts
+++ b/src/services/note/reaction/delete.ts
@@ -9,7 +9,7 @@ import { Note } from '../../../models/entities/note';
import { NoteReactions, Users, Notes } from '../../../models';
import { decodeReaction } from '@/misc/reaction-lib';
-export default async (user: User, note: Note) => {
+export default async (user: { id: User['id']; host: User['host']; }, note: Note) => {
// if already unreacted
const exist = await NoteReactions.findOne({
noteId: note.id,