diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-23 01:08:45 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-23 01:08:45 +0900 |
| commit | d0d5068f728e13f3ebe1dc227ddaacf380817ec4 (patch) | |
| tree | 7bb95207e01bff1bee9877829c0556d3ecf62176 /src/services | |
| parent | Merge branch 'develop' (diff) | |
| parent | 12.93.0 (diff) | |
| download | misskey-d0d5068f728e13f3ebe1dc227ddaacf380817ec4.tar.gz misskey-d0d5068f728e13f3ebe1dc227ddaacf380817ec4.tar.bz2 misskey-d0d5068f728e13f3ebe1dc227ddaacf380817ec4.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/blocking/create.ts | 4 | ||||
| -rw-r--r-- | src/services/logger.ts | 16 | ||||
| -rw-r--r-- | src/services/stream.ts | 53 |
3 files changed, 36 insertions, 37 deletions
diff --git a/src/services/blocking/create.ts b/src/services/blocking/create.ts index defe377514..6aadc847a9 100644 --- a/src/services/blocking/create.ts +++ b/src/services/blocking/create.ts @@ -12,10 +12,6 @@ import { genId } from '@/misc/gen-id'; import { IdentifiableError } from '@/misc/identifiable-error'; export default async function(blocker: User, blockee: User) { - if (blockee.isAdmin || blockee.isModerator) { - throw new IdentifiableError('e42b7890-5e4d-9d9c-d54b-cf4dd30adfb5'); - } - await Promise.all([ cancelRequest(blocker, blockee), cancelRequest(blockee, blocker), diff --git a/src/services/logger.ts b/src/services/logger.ts index 8e783e67f6..67ee441254 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -1,11 +1,7 @@ import * as cluster from 'cluster'; -import * as os from 'os'; import * as chalk from 'chalk'; import * as dateformat from 'dateformat'; import { envOption } from '../env'; -import { getRepository } from 'typeorm'; -import { Log } from '@/models/entities/log'; -import { genId } from '@/misc/gen-id'; import config from '@/config/index'; import * as SyslogPro from 'syslog-pro'; @@ -95,18 +91,6 @@ export default class Logger { null as never; send.bind(this.syslogClient)(message).catch(() => {}); - } else { - const Logs = getRepository(Log); - Logs.insert({ - id: genId(), - createdAt: new Date(), - machine: os.hostname(), - worker: worker.toString(), - domain: [this.domain].concat(subDomains).map(d => d.name), - level: level, - message: message.substr(0, 1000), // 1024を超えるとログが挿入できずエラーになり無限ループする - data: data, - } as Log).catch(() => {}); } } } diff --git a/src/services/stream.ts b/src/services/stream.ts index 4db1a77395..2c308a1b54 100644 --- a/src/services/stream.ts +++ b/src/services/stream.ts @@ -7,9 +7,28 @@ import { UserGroup } from '@/models/entities/user-group'; import config from '@/config/index'; import { Antenna } from '@/models/entities/antenna'; import { Channel } from '@/models/entities/channel'; +import { + StreamChannels, + AdminStreamTypes, + AntennaStreamTypes, + BroadcastTypes, + ChannelStreamTypes, + DriveStreamTypes, + GroupMessagingStreamTypes, + InternalStreamTypes, + MainStreamTypes, + MessagingIndexStreamTypes, + MessagingStreamTypes, + NoteStreamTypes, + ReversiGameStreamTypes, + ReversiStreamTypes, + UserListStreamTypes, + UserStreamTypes +} from '@/server/api/stream/types'; +import { Packed } from '@/misc/schema'; class Publisher { - private publish = (channel: string, type: string | null, value?: any): void => { + private publish = (channel: StreamChannels, type: string | null, value?: any): void => { const message = type == null ? value : value == null ? { type: type, body: null } : { type: type, body: value }; @@ -20,70 +39,70 @@ class Publisher { })); } - public publishInternalEvent = (type: string, value?: any): void => { + public publishInternalEvent = <K extends keyof InternalStreamTypes>(type: K, value?: InternalStreamTypes[K]): void => { this.publish('internal', type, typeof value === 'undefined' ? null : value); } - public publishUserEvent = (userId: User['id'], type: string, value?: any): void => { + public publishUserEvent = <K extends keyof UserStreamTypes>(userId: User['id'], type: K, value?: UserStreamTypes[K]): void => { this.publish(`user:${userId}`, type, typeof value === 'undefined' ? null : value); } - public publishBroadcastStream = (type: string, value?: any): void => { + public publishBroadcastStream = <K extends keyof BroadcastTypes>(type: K, value?: BroadcastTypes[K]): void => { this.publish('broadcast', type, typeof value === 'undefined' ? null : value); } - public publishMainStream = (userId: User['id'], type: string, value?: any): void => { + public publishMainStream = <K extends keyof MainStreamTypes>(userId: User['id'], type: K, value?: MainStreamTypes[K]): void => { this.publish(`mainStream:${userId}`, type, typeof value === 'undefined' ? null : value); } - public publishDriveStream = (userId: User['id'], type: string, value?: any): void => { + public publishDriveStream = <K extends keyof DriveStreamTypes>(userId: User['id'], type: K, value?: DriveStreamTypes[K]): void => { this.publish(`driveStream:${userId}`, type, typeof value === 'undefined' ? null : value); } - public publishNoteStream = (noteId: Note['id'], type: string, value: any): void => { + public publishNoteStream = <K extends keyof NoteStreamTypes>(noteId: Note['id'], type: K, value?: NoteStreamTypes[K]): void => { this.publish(`noteStream:${noteId}`, type, { id: noteId, body: value }); } - public publishChannelStream = (channelId: Channel['id'], type: string, value?: any): void => { + public publishChannelStream = <K extends keyof ChannelStreamTypes>(channelId: Channel['id'], type: K, value?: ChannelStreamTypes[K]): void => { this.publish(`channelStream:${channelId}`, type, typeof value === 'undefined' ? null : value); } - public publishUserListStream = (listId: UserList['id'], type: string, value?: any): void => { + public publishUserListStream = <K extends keyof UserListStreamTypes>(listId: UserList['id'], type: K, value?: UserListStreamTypes[K]): void => { this.publish(`userListStream:${listId}`, type, typeof value === 'undefined' ? null : value); } - public publishAntennaStream = (antennaId: Antenna['id'], type: string, value?: any): void => { + public publishAntennaStream = <K extends keyof AntennaStreamTypes>(antennaId: Antenna['id'], type: K, value?: AntennaStreamTypes[K]): void => { this.publish(`antennaStream:${antennaId}`, type, typeof value === 'undefined' ? null : value); } - public publishMessagingStream = (userId: User['id'], otherpartyId: User['id'], type: string, value?: any): void => { + public publishMessagingStream = <K extends keyof MessagingStreamTypes>(userId: User['id'], otherpartyId: User['id'], type: K, value?: MessagingStreamTypes[K]): void => { this.publish(`messagingStream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value); } - public publishGroupMessagingStream = (groupId: UserGroup['id'], type: string, value?: any): void => { + public publishGroupMessagingStream = <K extends keyof GroupMessagingStreamTypes>(groupId: UserGroup['id'], type: K, value?: GroupMessagingStreamTypes[K]): void => { this.publish(`messagingStream:${groupId}`, type, typeof value === 'undefined' ? null : value); } - public publishMessagingIndexStream = (userId: User['id'], type: string, value?: any): void => { + public publishMessagingIndexStream = <K extends keyof MessagingIndexStreamTypes>(userId: User['id'], type: K, value?: MessagingIndexStreamTypes[K]): void => { this.publish(`messagingIndexStream:${userId}`, type, typeof value === 'undefined' ? null : value); } - public publishReversiStream = (userId: User['id'], type: string, value?: any): void => { + public publishReversiStream = <K extends keyof ReversiStreamTypes>(userId: User['id'], type: K, value?: ReversiStreamTypes[K]): void => { this.publish(`reversiStream:${userId}`, type, typeof value === 'undefined' ? null : value); } - public publishReversiGameStream = (gameId: ReversiGame['id'], type: string, value?: any): void => { + public publishReversiGameStream = <K extends keyof ReversiGameStreamTypes>(gameId: ReversiGame['id'], type: K, value?: ReversiGameStreamTypes[K]): void => { this.publish(`reversiGameStream:${gameId}`, type, typeof value === 'undefined' ? null : value); } - public publishNotesStream = (note: any): void => { + public publishNotesStream = (note: Packed<'Note'>): void => { this.publish('notesStream', null, note); } - public publishAdminStream = (userId: User['id'], type: string, value?: any): void => { + public publishAdminStream = <K extends keyof AdminStreamTypes>(userId: User['id'], type: K, value?: AdminStreamTypes[K]): void => { this.publish(`adminStream:${userId}`, type, typeof value === 'undefined' ? null : value); } } |