This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -22,14 +22,14 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: {
if (!read) {
const mutings = await Mutings.find({
where: {
muterId: antenna.userId
muterId: antenna.userId,
},
select: ['muteeId']
select: ['muteeId'],
});
// Copy
const _note: Note = {
...note
...note,
};
if (note.replyId != null) {

View File

@ -36,7 +36,7 @@ export default async function(blocker: User, blockee: User) {
async function cancelRequest(follower: User, followee: User) {
const request = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (request == null) {
@ -45,18 +45,18 @@ async function cancelRequest(follower: User, followee: User) {
await FollowRequests.delete({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (Users.isLocalUser(followee)) {
Users.pack(followee, followee, {
detail: true
detail: true,
}).then(packed => publishMainStream(followee.id, 'meUpdated', packed));
}
if (Users.isLocalUser(follower)) {
Users.pack(followee, follower, {
detail: true
detail: true,
}).then(packed => {
publishUserEvent(follower.id, 'unfollow', packed);
publishMainStream(follower.id, 'unfollow', packed);
@ -79,7 +79,7 @@ async function cancelRequest(follower: User, followee: User) {
async function unFollow(follower: User, followee: User) {
const following = await Followings.findOne({
followerId: follower.id,
followeeId: followee.id
followeeId: followee.id,
});
if (following == null) {
@ -101,7 +101,7 @@ async function unFollow(follower: User, followee: User) {
// Publish unfollow event
if (Users.isLocalUser(follower)) {
Users.pack(followee, follower, {
detail: true
detail: true,
}).then(packed => {
publishUserEvent(follower.id, 'unfollow', packed);
publishMainStream(follower.id, 'unfollow', packed);

View File

@ -11,7 +11,7 @@ const logger = new Logger('blocking/delete');
export default async function(blocker: User, blockee: User) {
const blocking = await Blockings.findOne({
blockerId: blocker.id,
blockeeId: blockee.id
blockeeId: blockee.id,
});
if (blocking == null) {

View File

@ -37,11 +37,11 @@ export default class ActiveUsersChart extends Chart<ActiveUsersLog> {
@autobind
public async update(user: { id: User['id'], host: User['host'] }) {
const update: Obj = {
users: [user.id]
users: [user.id],
};
await this.inc({
[Users.isLocalUser(user) ? 'local' : 'remote']: update
[Users.isLocalUser(user) ? 'local' : 'remote']: update,
});
}
}

View File

@ -23,7 +23,7 @@ export default class DriveChart extends Chart<DriveLog> {
remote: {
totalCount: latest.remote.totalCount,
totalSize: latest.remote.totalSize,
}
},
};
}
@ -55,7 +55,7 @@ export default class DriveChart extends Chart<DriveLog> {
DriveFiles.count({ userHost: null }),
DriveFiles.count({ userHost: Not(IsNull()) }),
DriveFiles.calcDriveUsageOfLocal(),
DriveFiles.calcDriveUsageOfRemote()
DriveFiles.calcDriveUsageOfRemote(),
]);
return {
@ -66,7 +66,7 @@ export default class DriveChart extends Chart<DriveLog> {
remote: {
totalCount: remoteCount,
totalSize: remoteSize,
}
},
};
}
@ -85,7 +85,7 @@ export default class DriveChart extends Chart<DriveLog> {
}
await this.inc({
[file.userHost === null ? 'local' : 'remote']: update
[file.userHost === null ? 'local' : 'remote']: update,
});
}
}

View File

@ -16,7 +16,7 @@ export default class FederationChart extends Chart<FederationLog> {
return {
instance: {
total: latest.instance.total,
}
},
};
}
@ -34,13 +34,13 @@ export default class FederationChart extends Chart<FederationLog> {
@autobind
protected async fetchActual(): Promise<DeepPartial<FederationLog>> {
const [total] = await Promise.all([
Instances.count({})
Instances.count({}),
]);
return {
instance: {
total: total,
}
},
};
}
@ -56,7 +56,7 @@ export default class FederationChart extends Chart<FederationLog> {
}
await this.inc({
instance: update
instance: update,
});
}
}

View File

@ -37,11 +37,11 @@ export default class HashtagChart extends Chart<HashtagLog> {
@autobind
public async update(hashtag: string, user: { id: User['id'], host: User['host'] }) {
const update: Obj = {
users: [user.id]
users: [user.id],
};
await this.inc({
[Users.isLocalUser(user) ? 'local' : 'remote']: update
[Users.isLocalUser(user) ? 'local' : 'remote']: update,
}, hashtag);
}
}

View File

@ -32,7 +32,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
drive: {
totalFiles: latest.drive.totalFiles,
totalUsage: latest.drive.totalUsage,
}
},
};
}
@ -114,7 +114,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
drive: {
totalFiles: driveFiles,
totalUsage: driveUsage,
}
},
};
}
@ -122,8 +122,8 @@ export default class InstanceChart extends Chart<InstanceLog> {
public async requestReceived(host: string) {
await this.inc({
requests: {
received: 1
}
received: 1,
},
}, toPuny(host));
}
@ -138,7 +138,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
}
await this.inc({
requests: update
requests: update,
}, toPuny(host));
}
@ -147,8 +147,8 @@ export default class InstanceChart extends Chart<InstanceLog> {
await this.inc({
users: {
total: 1,
inc: 1
}
inc: 1,
},
}, toPuny(host));
}
@ -169,8 +169,8 @@ export default class InstanceChart extends Chart<InstanceLog> {
total: isAdditional ? 1 : -1,
inc: isAdditional ? 1 : 0,
dec: isAdditional ? 0 : 1,
diffs: diffs
}
diffs: diffs,
},
}, toPuny(host));
}
@ -181,7 +181,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
total: isAdditional ? 1 : -1,
inc: isAdditional ? 1 : 0,
dec: isAdditional ? 0 : 1,
}
},
}, toPuny(host));
}
@ -192,7 +192,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
total: isAdditional ? 1 : -1,
inc: isAdditional ? 1 : 0,
dec: isAdditional ? 0 : 1,
}
},
}, toPuny(host));
}
@ -211,7 +211,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
}
await this.inc({
drive: update
drive: update,
}, file.userHost);
}
}

View File

@ -37,7 +37,7 @@ export default class NetworkChart extends Chart<NetworkLog> {
incomingRequests: incomingRequests,
totalTime: time,
incomingBytes: incomingBytes,
outgoingBytes: outgoingBytes
outgoingBytes: outgoingBytes,
};
await this.inc(inc);

View File

@ -21,7 +21,7 @@ export default class NotesChart extends Chart<NotesLog> {
},
remote: {
total: latest.remote.total,
}
},
};
}
@ -55,7 +55,7 @@ export default class NotesChart extends Chart<NotesLog> {
protected async fetchActual(): Promise<DeepPartial<NotesLog>> {
const [localCount, remoteCount] = await Promise.all([
Notes.count({ userHost: null }),
Notes.count({ userHost: Not(IsNull()) })
Notes.count({ userHost: Not(IsNull()) }),
]);
return {
@ -64,14 +64,14 @@ export default class NotesChart extends Chart<NotesLog> {
},
remote: {
total: remoteCount,
}
},
};
}
@autobind
public async update(note: Note, isAdditional: boolean) {
const update: Obj = {
diffs: {}
diffs: {},
};
update.total = isAdditional ? 1 : -1;
@ -91,7 +91,7 @@ export default class NotesChart extends Chart<NotesLog> {
}
await this.inc({
[note.userHost === null ? 'local' : 'remote']: update
[note.userHost === null ? 'local' : 'remote']: update,
});
}
}

View File

@ -36,7 +36,7 @@ export default class PerUserDriveChart extends Chart<PerUserDriveLog> {
protected async fetchActual(group: string): Promise<DeepPartial<PerUserDriveLog>> {
const [count, size] = await Promise.all([
DriveFiles.count({ userId: group }),
DriveFiles.calcDriveUsageOf(group)
DriveFiles.calcDriveUsageOf(group),
]);
return {

View File

@ -22,7 +22,7 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
},
followers: {
total: latest.local.followers.total,
}
},
},
remote: {
followings: {
@ -30,8 +30,8 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
},
followers: {
total: latest.remote.followers.total,
}
}
},
},
};
}
@ -71,12 +71,12 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
localFollowingsCount,
localFollowersCount,
remoteFollowingsCount,
remoteFollowersCount
remoteFollowersCount,
] = await Promise.all([
Followings.count({ followerId: group, followeeHost: null }),
Followings.count({ followeeId: group, followerHost: null }),
Followings.count({ followerId: group, followeeHost: Not(IsNull()) }),
Followings.count({ followeeId: group, followerHost: Not(IsNull()) })
Followings.count({ followeeId: group, followerHost: Not(IsNull()) }),
]);
return {
@ -86,7 +86,7 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
},
followers: {
total: localFollowersCount,
}
},
},
remote: {
followings: {
@ -94,8 +94,8 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
},
followers: {
total: remoteFollowersCount,
}
}
},
},
};
}
@ -112,10 +112,10 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
}
this.inc({
[Users.isLocalUser(follower) ? 'local' : 'remote']: { followings: update }
[Users.isLocalUser(follower) ? 'local' : 'remote']: { followings: update },
}, follower.id);
this.inc({
[Users.isLocalUser(followee) ? 'local' : 'remote']: { followers: update }
[Users.isLocalUser(followee) ? 'local' : 'remote']: { followers: update },
}, followee.id);
}
}

View File

@ -48,7 +48,7 @@ export default class PerUserNotesChart extends Chart<PerUserNotesLog> {
@autobind
public async update(user: { id: User['id'] }, note: Note, isAdditional: boolean) {
const update: Obj = {
diffs: {}
diffs: {},
};
update.total = isAdditional ? 1 : -1;

View File

@ -38,7 +38,7 @@ export default class PerUserReactionsChart extends Chart<PerUserReactionsLog> {
@autobind
public async update(user: { id: User['id'], host: User['host'] }, note: Note) {
this.inc({
[Users.isLocalUser(user) ? 'local' : 'remote']: { count: 1 }
[Users.isLocalUser(user) ? 'local' : 'remote']: { count: 1 },
}, note.userId);
}
}

View File

@ -52,7 +52,7 @@ export default class TestGroupedChart extends Chart<TestGroupedLog> {
this.total[group]++;
await this.inc({
foo: update
foo: update,
}, group);
}
}

View File

@ -30,7 +30,7 @@ export default class TestUniqueChart extends Chart<TestUniqueLog> {
@autobind
public async uniqueIncrement(key: string) {
await this.inc({
foo: [key]
foo: [key],
});
}
}

View File

@ -50,7 +50,7 @@ export default class TestChart extends Chart<TestLog> {
this.total++;
await this.inc({
foo: update
foo: update,
});
}
@ -63,7 +63,7 @@ export default class TestChart extends Chart<TestLog> {
this.total--;
await this.inc({
foo: update
foo: update,
});
}
}

View File

@ -21,7 +21,7 @@ export default class UsersChart extends Chart<UsersLog> {
},
remote: {
total: latest.remote.total,
}
},
};
}
@ -45,7 +45,7 @@ export default class UsersChart extends Chart<UsersLog> {
protected async fetchActual(): Promise<DeepPartial<UsersLog>> {
const [localCount, remoteCount] = await Promise.all([
Users.count({ host: null }),
Users.count({ host: Not(IsNull()) })
Users.count({ host: Not(IsNull()) }),
]);
return {
@ -54,7 +54,7 @@ export default class UsersChart extends Chart<UsersLog> {
},
remote: {
total: remoteCount,
}
},
};
}
@ -70,7 +70,7 @@ export default class UsersChart extends Chart<UsersLog> {
}
await this.inc({
[Users.isLocalUser(user) ? 'local' : 'remote']: update
[Users.isLocalUser(user) ? 'local' : 'remote']: update,
});
}
}

View File

@ -8,7 +8,7 @@ export const logSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
},
},
};
@ -22,14 +22,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'activeUsers';

View File

@ -55,14 +55,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'drive';

View File

@ -21,9 +21,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
}
}
},
},
},
};
export const name = 'federation';

View File

@ -8,7 +8,7 @@ export const logSchema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
},
},
};
@ -22,14 +22,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'hashtag';

View File

@ -21,7 +21,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
notes: {
@ -59,9 +59,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
}
},
},
users: {
@ -80,7 +80,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
following: {
@ -99,7 +99,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
followers: {
@ -118,7 +118,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
drive: {
@ -149,9 +149,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
}
},
};
export const name = 'instance';

View File

@ -25,7 +25,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
};
export const name = 'network';

View File

@ -32,7 +32,7 @@ const logSchema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
};
@ -43,14 +43,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'notes';

View File

@ -49,7 +49,7 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
};
export const name = 'perUserDrive';

View File

@ -29,7 +29,7 @@ export const logSchema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
/**
@ -62,7 +62,7 @@ export const logSchema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
};
@ -73,14 +73,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'perUserFollowing';

View File

@ -35,9 +35,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
},
},
}
},
};
export const name = 'perUserNotes';

View File

@ -18,14 +18,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'perUserReaction';

View File

@ -20,9 +20,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
}
}
},
},
},
};
export const name = 'testGrouped';

View File

@ -8,9 +8,9 @@ export const schema = {
items: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
},
},
}
},
};
export const name = 'testUnique';

View File

@ -20,9 +20,9 @@ export const schema = {
type: 'number' as const,
optional: false as const, nullable: false as const,
},
}
}
}
},
},
},
};
export const name = 'test';

View File

@ -31,14 +31,14 @@ export const schema = {
local: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
remote: {
type: 'object' as const,
optional: false as const, nullable: false as const,
properties: logSchema
properties: logSchema,
},
}
},
};
export const name = 'users';

View File

@ -188,7 +188,7 @@ export default abstract class Chart<T extends Record<string, any>> {
id: {
type: 'integer',
primary: true,
generated: true
generated: true,
},
date: {
type: 'integer',
@ -196,9 +196,9 @@ export default abstract class Chart<T extends Record<string, any>> {
group: {
type: 'varchar',
length: 128,
nullable: true
nullable: true,
},
...Chart.convertSchemaToFlatColumnDefinitions(schema)
...Chart.convertSchemaToFlatColumnDefinitions(schema),
},
indices: [{
columns: ['date', 'group'],
@ -206,8 +206,8 @@ export default abstract class Chart<T extends Record<string, any>> {
}, { // groupにnullが含まれると↑のuniqueは機能しないので↓の部分インデックスでカバー
columns: ['date'],
unique: true,
where: '"group" IS NULL'
}]
where: '"group" IS NULL',
}],
});
}
@ -220,7 +220,7 @@ export default abstract class Chart<T extends Record<string, any>> {
if (grouped) keys.push('group');
entity.options.uniques = [{
columns: keys
columns: keys,
}];
this.repository = getRepository<Log>(entity);
@ -252,8 +252,8 @@ export default abstract class Chart<T extends Record<string, any>> {
group: group,
}, {
order: {
date: -1
}
date: -1,
},
}).then(x => x || null);
}
@ -266,7 +266,7 @@ export default abstract class Chart<T extends Record<string, any>> {
// 現在(=今のHour)のログ
const currentLog = await this.repository.findOne({
date: Chart.dateToTimestamp(current),
...(group ? { group: group } : {})
...(group ? { group: group } : {}),
});
// ログがあればそれを返して終了
@ -308,7 +308,7 @@ export default abstract class Chart<T extends Record<string, any>> {
// ロック内でもう1回チェックする
const currentLog = await this.repository.findOne({
date: date,
...(group ? { group: group } : {})
...(group ? { group: group } : {}),
});
// ログがあればそれを返して終了
@ -318,7 +318,7 @@ export default abstract class Chart<T extends Record<string, any>> {
log = await this.repository.insert({
group: group,
date: date,
...Chart.convertObjectToFlattenColumns(data)
...Chart.convertObjectToFlattenColumns(data),
}).then(x => this.repository.findOneOrFail(x.identifiers[0]));
logger.info(`${this.name + (group ? `:${group}` : '')}: New commit created`);
@ -424,10 +424,10 @@ export default abstract class Chart<T extends Record<string, any>> {
let logs = await this.repository.find({
where: {
group: group,
date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt))
date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt)),
},
order: {
date: -1
date: -1,
},
});
@ -439,7 +439,7 @@ export default abstract class Chart<T extends Record<string, any>> {
group: group,
}, {
order: {
date: -1
date: -1,
},
});
@ -453,10 +453,10 @@ export default abstract class Chart<T extends Record<string, any>> {
// (隙間埋めできないため)
const outdatedLog = await this.repository.findOne({
group: group,
date: LessThan(Chart.dateToTimestamp(gt))
date: LessThan(Chart.dateToTimestamp(gt)),
}, {
order: {
date: -1
date: -1,
},
});

View File

@ -11,5 +11,5 @@ export const entities = Object.values(require('require-all')({
filter: /^.+\.[jt]s$/,
resolve: (x: any) => {
return Chart.schemaToEntity(x.name, x.schema);
}
},
}));

View File

@ -27,7 +27,7 @@ export async function createNotification(
type: type,
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
isRead: isMuted,
...data
...data,
} as Partial<Notification>);
const packed = await Notifications.pack(notification, {});
@ -43,7 +43,7 @@ export async function createNotification(
//#region ただしミュートしているユーザーからの通知なら無視
const mutings = await Mutings.find({
muterId: notifieeId
muterId: notifieeId,
});
if (data.notifierId && mutings.map(m => m.muteeId).includes(data.notifierId)) {
return;

View File

@ -27,7 +27,7 @@ export async function createSystemUser(username: string) {
await getConnection().transaction(async transactionalEntityManager => {
const exist = await transactionalEntityManager.findOne(User, {
usernameLower: username.toLowerCase(),
host: null
host: null,
});
if (exist) throw new Error('the user is already exists');
@ -48,7 +48,7 @@ export async function createSystemUser(username: string) {
await transactionalEntityManager.insert(UserKeypair, {
publicKey: keyPair.publicKey,
privateKey: keyPair.privateKey,
userId: account.id
userId: account.id,
});
await transactionalEntityManager.insert(UserProfile, {

View File

@ -66,7 +66,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
//#region Uploads
logger.info(`uploading original: ${key}`);
const uploads = [
upload(key, fs.createReadStream(path), type, name)
upload(key, fs.createReadStream(path), type, name),
];
if (alts.webpublic) {
@ -149,13 +149,13 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
const thumbnail = await GenerateVideoThumbnail(path);
return {
webpublic: null,
thumbnail
thumbnail,
};
} catch (e) {
logger.warn(`GenerateVideoThumbnail failed: ${e}`);
return {
webpublic: null,
thumbnail: null
thumbnail: null,
};
}
}
@ -164,7 +164,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
logger.debug(`web image and thumbnail not created (not an required file)`);
return {
webpublic: null,
thumbnail: null
thumbnail: null,
};
}
@ -179,14 +179,14 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
if (isAnimated) {
return {
webpublic: null,
thumbnail: null
thumbnail: null,
};
}
} catch (e) {
logger.warn(`sharp failed: ${e}`);
return {
webpublic: null,
thumbnail: null
thumbnail: null,
};
}
@ -258,7 +258,7 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,
const s3 = getS3(meta);
const upload = s3.upload(params, {
partSize: s3.endpoint?.hostname === 'storage.googleapis.com' ? 500 * 1024 * 1024 : 8 * 1024 * 1024
partSize: s3.endpoint?.hostname === 'storage.googleapis.com' ? 500 * 1024 * 1024 : 8 * 1024 * 1024,
});
const result = await upload.promise();
@ -361,7 +361,7 @@ export default async function(
const driveFolder = await DriveFolders.findOne({
id: folderId,
userId: user ? user.id : null
userId: user ? user.id : null,
});
if (driveFolder == null) throw new Error('folder-not-found');
@ -436,7 +436,7 @@ export default async function(
file = await DriveFiles.findOne({
uri: file.uri,
userId: user ? user.id : null
userId: user ? user.id : null,
}) as DriveFile;
} else {
logger.error(e);

View File

@ -98,6 +98,6 @@ export async function deleteObjectStorageFile(key: string) {
await s3.deleteObject({
Bucket: meta.objectStorageBucket!,
Key: key
Key: key,
}).promise();
}

View File

@ -13,7 +13,7 @@ export async function GenerateVideoThumbnail(path: string): Promise<IImage> {
await new Promise((res, rej) => {
FFmpeg({
source: path
source: path,
})
.on('end', res)
.on('error', rej)
@ -21,7 +21,7 @@ export async function GenerateVideoThumbnail(path: string): Promise<IImage> {
folder: outDir,
filename: 'output.png',
count: 1,
timestamps: ['5%']
timestamps: ['5%'],
});
});

View File

@ -18,19 +18,19 @@ export async function convertSharpToJpeg(sharp: sharp.Sharp, width: number, heig
const data = await sharp
.resize(width, height, {
fit: 'inside',
withoutEnlargement: true
withoutEnlargement: true,
})
.rotate()
.jpeg({
quality: 85,
progressive: true
progressive: true,
})
.toBuffer();
return {
data,
ext: 'jpg',
type: 'image/jpeg'
type: 'image/jpeg',
};
}
@ -46,18 +46,18 @@ export async function convertSharpToWebp(sharp: sharp.Sharp, width: number, heig
const data = await sharp
.resize(width, height, {
fit: 'inside',
withoutEnlargement: true
withoutEnlargement: true,
})
.rotate()
.webp({
quality: 85
quality: 85,
})
.toBuffer();
return {
data,
ext: 'webp',
type: 'image/webp'
type: 'image/webp',
};
}
@ -73,7 +73,7 @@ export async function convertSharpToPng(sharp: sharp.Sharp, width: number, heigh
const data = await sharp
.resize(width, height, {
fit: 'inside',
withoutEnlargement: true
withoutEnlargement: true,
})
.rotate()
.png()
@ -82,7 +82,7 @@ export async function convertSharpToPng(sharp: sharp.Sharp, width: number, heigh
return {
data,
ext: 'png',
type: 'image/png'
type: 'image/png',
};
}

View File

@ -18,7 +18,7 @@ export function getS3(meta: Meta) {
? false
: meta.objectStorageS3ForcePathStyle,
httpOptions: {
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy)
}
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy),
},
});
}

View File

@ -47,7 +47,7 @@ export default async (
error = e;
logger.error(`Failed to create drive file: ${e}`, {
url: url,
e: e
e: e,
});
}

View File

@ -34,7 +34,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
followerSharedInbox: Users.isRemoteUser(follower) ? follower.sharedInbox : null,
followeeHost: followee.host,
followeeInbox: Users.isRemoteUser(followee) ? followee.inbox : null,
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : null
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : null,
}).catch(e => {
if (isDuplicateKeyValueError(e) && Users.isRemoteUser(follower) && Users.isLocalUser(followee)) {
logger.info(`Insert duplicated ignore. ${follower.id} => ${followee.id}`);
@ -46,13 +46,13 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
const req = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (req) {
await FollowRequests.delete({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
// 通知を作成
@ -87,7 +87,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
// Publish follow event
if (Users.isLocalUser(follower)) {
Users.pack(followee.id, follower, {
detail: true
detail: true,
}).then(packed => {
publishUserEvent(follower.id, 'follow', packed);
publishMainStream(follower.id, 'follow', packed);
@ -100,7 +100,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
// 通知を作成
createNotification(followee.id, 'follow', {
notifierId: follower.id
notifierId: follower.id,
});
}
}
@ -108,7 +108,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
export default async function(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string) {
const [follower, followee] = await Promise.all([
Users.findOneOrFail(_follower.id),
Users.findOneOrFail(_followee.id)
Users.findOneOrFail(_followee.id),
]);
// check blocking
@ -120,7 +120,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us
Blockings.findOne({
blockerId: followee.id,
blockeeId: follower.id,
})
}),
]);
if (Users.isRemoteUser(follower) && Users.isLocalUser(followee) && blocked) {
@ -159,7 +159,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us
if (!autoAccept && (Users.isLocalUser(followee) && followeeProfile.autoAcceptFollowed)) {
const followed = await Followings.findOne({
followerId: followee.id,
followeeId: follower.id
followeeId: follower.id,
});
if (followed) autoAccept = true;

View File

@ -15,7 +15,7 @@ const logger = new Logger('following/delete');
export default async function(follower: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, followee: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, silent = false) {
const following = await Followings.findOne({
followerId: follower.id,
followeeId: followee.id
followeeId: followee.id,
});
if (following == null) {
@ -30,7 +30,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
// Publish unfollow event
if (!silent && Users.isLocalUser(follower)) {
Users.pack(followee.id, follower, {
detail: true
detail: true,
}).then(packed => {
publishUserEvent(follower.id, 'unfollow', packed);
publishMainStream(follower.id, 'unfollow', packed);

View File

@ -56,7 +56,7 @@ export async function remoteReject(actor: Remote, follower: Local) {
async function removeFollowRequest(followee: Both, follower: Both) {
const request = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (!request) return;
@ -70,7 +70,7 @@ async function removeFollowRequest(followee: Both, follower: Both) {
async function removeFollow(followee: Both, follower: Both) {
const following = await Followings.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (!following) return;
@ -85,7 +85,7 @@ async function removeFollow(followee: Both, follower: Both) {
async function deliverReject(followee: Local, follower: Remote) {
const request = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
const content = renderActivity(renderReject(renderFollow(follower, followee, request?.requestId || undefined), followee));
@ -97,7 +97,7 @@ async function deliverReject(followee: Local, follower: Remote) {
*/
async function publishUnfollow(followee: Both, follower: Local) {
const packedFollowee = await Users.pack(followee.id, follower, {
detail: true
detail: true,
});
publishUserEvent(follower.id, 'unfollow', packedFollowee);

View File

@ -8,7 +8,7 @@ import { FollowRequests, Users } from '@/models/index';
*/
export default async function(user: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }) {
const requests = await FollowRequests.find({
followeeId: user.id
followeeId: user.id,
});
for (const request of requests) {

View File

@ -11,7 +11,7 @@ import { IdentifiableError } from '@/misc/identifiable-error';
export default async function(followee: { id: User['id']; host: User['host']; uri: User['host']; inbox: User['inbox']; sharedInbox: User['sharedInbox']; }, follower: User) {
const request = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (request == null) {
@ -26,6 +26,6 @@ export default async function(followee: { id: User['id']; host: User['host']; ur
}
Users.pack(followee.id, followee, {
detail: true
detail: true,
}).then(packed => publishMainStream(followee.id, 'meUpdated', packed));
}

View File

@ -18,7 +18,7 @@ export default async function(followee: { id: User['id']; host: User['host']; ur
const request = await FollowRequests.findOne({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
if (request == null) {
@ -27,10 +27,10 @@ export default async function(followee: { id: User['id']; host: User['host']; ur
await FollowRequests.delete({
followeeId: followee.id,
followerId: follower.id
followerId: follower.id,
});
Users.pack(followee.id, followee, {
detail: true
detail: true,
}).then(packed => publishMainStream(followee.id, 'meUpdated', packed));
}

View File

@ -19,7 +19,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
Blockings.findOne({
blockerId: followee.id,
blockeeId: follower.id,
})
}),
]);
if (blocking != null) throw new Error('blocking');
@ -38,7 +38,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
followerSharedInbox: Users.isRemoteUser(follower) ? follower.sharedInbox : undefined,
followeeHost: followee.host,
followeeInbox: Users.isRemoteUser(followee) ? followee.inbox : undefined,
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : undefined
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : undefined,
});
// Publish receiveRequest event
@ -46,13 +46,13 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
Users.pack(follower.id, followee).then(packed => publishMainStream(followee.id, 'receiveFollowRequest', packed));
Users.pack(followee.id, followee, {
detail: true
detail: true,
}).then(packed => publishMainStream(followee.id, 'meUpdated', packed));
// 通知を作成
createNotification(followee.id, 'receiveFollowRequest', {
notifierId: follower.id,
followRequestId: followRequest.id
followRequestId: followRequest.id,
});
}

View File

@ -20,7 +20,7 @@ export async function addPinned(user: { id: User['id']; host: User['host']; }, n
// Fetch pinee
const note = await Notes.findOne({
id: noteId,
userId: user.id
userId: user.id,
});
if (note == null) {
@ -41,7 +41,7 @@ export async function addPinned(user: { id: User['id']; host: User['host']; }, n
id: genId(),
createdAt: new Date(),
userId: user.id,
noteId: note.id
noteId: note.id,
} as UserNotePining);
// Deliver to remote followers
@ -59,7 +59,7 @@ export async function removePinned(user: { id: User['id']; host: User['host']; }
// Fetch unpinee
const note = await Notes.findOne({
id: noteId,
userId: user.id
userId: user.id,
});
if (note == null) {
@ -68,7 +68,7 @@ export async function removePinned(user: { id: User['id']; host: User['host']; }
UserNotePinings.delete({
userId: user.id,
noteId: note.id
noteId: note.id,
});
// Deliver to remote followers

View File

@ -8,6 +8,6 @@ export async function insertModerationLog(moderator: { id: User['id'] }, type: s
createdAt: new Date(),
userId: moderator.id,
type: type,
info: info || {}
info: info || {},
});
}

View File

@ -13,7 +13,7 @@ export async function getInstanceActor(): Promise<ILocalUser> {
const user = await Users.findOne({
host: null,
username: ACTOR_USERNAME
username: ACTOR_USERNAME,
}) as ILocalUser | undefined;
if (user) {

View File

@ -36,7 +36,7 @@ export default class Logger {
server: {
target: config.syslog.host,
port: config.syslog.port,
}
},
});
}
}

View File

@ -24,7 +24,7 @@ export async function createMessage(user: { id: User['id']; host: User['host'];
userId: user.id,
isRead: false,
reads: [] as any[],
uri
uri,
} as MessagingMessage;
await MessagingMessages.insert(message);
@ -96,7 +96,7 @@ export async function createMessage(user: { id: User['id']; host: User['host'];
mentionedRemoteUsers: JSON.stringify([ recipientUser ].map(u => ({
uri: u.uri,
username: u.username,
host: u.host
host: u.host,
}))),
} as Note;

View File

@ -65,7 +65,7 @@ class NotificationManager {
} else {
this.queue.push({
reason: reason,
target: notifiee
target: notifiee,
});
}
}
@ -74,7 +74,7 @@ class NotificationManager {
for (const x of this.queue) {
// ミュート情報を取得
const mentioneeMutes = await Mutings.find({
muterId: x.target
muterId: x.target,
});
const mentioneesMutedUserIds = mentioneeMutes.map(m => m.muteeId);
@ -83,7 +83,7 @@ class NotificationManager {
if (!mentioneesMutedUserIds.includes(this.notifier.id)) {
createNotification(x.target, x.reason, {
notifierId: this.notifier.id,
noteId: this.note.id
noteId: this.note.id,
});
}
}
@ -242,7 +242,7 @@ export default async (user: { id: User['id']; username: User['username']; host:
// Word mute
// TODO: cache
UserProfiles.find({
enableWordMute: true
enableWordMute: true,
}).then(us => {
for (const u of us) {
checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
@ -450,7 +450,7 @@ function incRenoteCount(renote: Note) {
Notes.createQueryBuilder().update()
.set({
renoteCount: () => '"renoteCount" + 1',
score: () => '"score" + 1'
score: () => '"score" + 1',
})
.where('id = :id', { id: renote.id })
.execute();
@ -508,7 +508,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
uri: u.uri,
url: url == null ? undefined : url,
username: u.username,
host: u.host
host: u.host,
} as IMentionedRemoteUsers[0];
}));
}
@ -528,7 +528,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
votes: new Array(data.poll!.choices.length).fill(0),
noteVisibility: insert.visibility,
userId: user.id,
userHost: user.host
userHost: user.host,
});
await transactionalEntityManager.insert(Poll, poll);
@ -561,15 +561,15 @@ function index(note: Note) {
body: {
text: normalizeForSearch(note.text),
userId: note.userId,
userHost: note.userHost
}
userHost: note.userHost,
},
});
}
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)
userId: Not(user.id),
});
for (const watcher of watchers) {
@ -580,7 +580,7 @@ async function notifyToWatchersOfRenotee(renote: Note, user: { id: User['id']; }
async function notifyToWatchersOfReplyee(reply: Note, user: { id: User['id']; }, nm: NotificationManager) {
const watchers = await NoteWatchings.find({
noteId: reply.id,
userId: Not(user.id)
userId: Not(user.id),
});
for (const watcher of watchers) {
@ -600,7 +600,7 @@ async function createMentionedEvents(mentionedUsers: User[], note: Note, nm: Not
}
const detailPackedNote = await Notes.pack(note, u, {
detail: true
detail: true,
});
publishMainStream(u.id, 'mention', detailPackedNote);
@ -618,7 +618,7 @@ function incNotesCountOfUser(user: { id: User['id']; }) {
Users.createQueryBuilder().update()
.set({
updatedAt: new Date(),
notesCount: () => '"notesCount" + 1'
notesCount: () => '"notesCount" + 1',
})
.where('id = :id', { id: user.id })
.execute();

View File

@ -31,7 +31,7 @@ export default async function(user: User, note: Note, quiet = false) {
if (!quiet) {
publishNoteStream(note.id, 'deleted', {
deletedAt: deletedAt
deletedAt: deletedAt,
});
//#region ローカルの投稿なら削除アクティビティを配送
@ -41,7 +41,7 @@ export default async function(user: User, note: Note, quiet = false) {
// if deletd note is renote
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length == 0)) {
renote = await Notes.findOne({
id: note.renoteId
id: note.renoteId,
});
}
@ -76,7 +76,7 @@ export default async function(user: User, note: Note, quiet = false) {
await Notes.delete({
id: note.id,
userId: user.id
userId: user.id,
});
}
@ -116,14 +116,14 @@ async function getMentionedRemoteUsers(note: Note) {
// renote / quote
if (note.renoteUserId) {
where.push({
id: note.renoteUserId
id: note.renoteUserId,
});
}
if (where.length === 0) return [];
return await Users.find({
where
where,
}) as IRemoteUser[];
}

View File

@ -28,7 +28,7 @@ export default async function(user: User, note: Note, choice: number) {
// if already voted
const exist = await PollVotes.find({
noteId: note.id,
userId: user.id
userId: user.id,
});
if (poll.multiple) {
@ -45,7 +45,7 @@ export default async function(user: User, note: Note, choice: number) {
createdAt: new Date(),
noteId: note.id,
userId: user.id,
choice: choice
choice: choice,
});
// Increment votes count
@ -54,14 +54,14 @@ export default async function(user: User, note: Note, choice: number) {
publishNoteStream(note.id, 'pollVoted', {
choice: choice,
userId: user.id
userId: user.id,
});
// Notify
createNotification(note.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice
choice: choice,
});
// Fetch watchers
@ -74,7 +74,7 @@ export default async function(user: User, note: Note, choice: number) {
createNotification(watcher.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice
choice: choice,
});
}
});

View File

@ -35,7 +35,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createdAt: new Date(),
noteId: note.id,
userId: user.id,
reaction
reaction,
};
// Create reaction
@ -66,7 +66,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
await Notes.createQueryBuilder().update()
.set({
reactions: () => sql,
score: () => '"score" + 1'
score: () => '"score" + 1',
})
.where('id = :id', { id: note.id })
.execute();
@ -79,22 +79,22 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
let emoji = await Emojis.findOne({
where: {
name: decodedReaction.name,
host: decodedReaction.host
host: decodedReaction.host,
},
select: ['name', 'host', 'url']
select: ['name', 'host', 'url'],
});
if (emoji) {
emoji = {
name: emoji.host ? `${emoji.name}@${emoji.host}` : `${emoji.name}@.`,
url: emoji.url
url: emoji.url,
} as any;
}
publishNoteStream(note.id, 'reacted', {
reaction: decodedReaction.reaction,
emoji: emoji,
userId: user.id
userId: user.id,
});
// リアクションされたユーザーがローカルユーザーなら通知を作成
@ -102,20 +102,20 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createNotification(note.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction
reaction: reaction,
});
}
// Fetch watchers
NoteWatchings.find({
noteId: note.id,
userId: Not(user.id)
userId: Not(user.id),
}).then(watchers => {
for (const watcher of watchers) {
createNotification(watcher.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction
reaction: reaction,
});
}
});

View File

@ -40,7 +40,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note)
publishNoteStream(note.id, 'unreacted', {
reaction: decodeReaction(exist.reaction).reaction,
userId: user.id
userId: user.id,
});
//#region 配信

View File

@ -22,15 +22,15 @@ export default async function(
) {
const following = info?.following ? info.following : new Set<string>((await Followings.find({
where: {
followerId: userId
followerId: userId,
},
select: ['followeeId']
select: ['followeeId'],
})).map(x => x.followeeId));
const followingChannels = info?.followingChannels ? info.followingChannels : new Set<string>((await ChannelFollowings.find({
where: {
followerId: userId
followerId: userId,
},
select: ['followeeId']
select: ['followeeId'],
})).map(x => x.followeeId));
const myAntennas = (await getAntennas()).filter(a => a.userId === userId);
@ -70,7 +70,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
isMentioned: true
isMentioned: true,
}).then(mentionsCount => {
if (mentionsCount === 0) {
// 全て既読になったイベントを発行
@ -80,7 +80,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
isSpecified: true
isSpecified: true,
}).then(specifiedCount => {
if (specifiedCount === 0) {
// 全て既読になったイベントを発行
@ -90,7 +90,7 @@ export default async function(
NoteUnreads.count({
userId: userId,
noteChannelId: Not(IsNull())
noteChannelId: Not(IsNull()),
}).then(channelNoteCount => {
if (channelNoteCount === 0) {
// 全て既読になったイベントを発行
@ -106,16 +106,16 @@ export default async function(
if (readAntennaNotes.length > 0) {
await AntennaNotes.update({
antennaId: In(myAntennas.map(a => a.id)),
noteId: In(readAntennaNotes.map(n => n.id))
noteId: In(readAntennaNotes.map(n => n.id)),
}, {
read: true
read: true,
});
// TODO: まとめてクエリしたい
for (const antenna of myAntennas) {
const count = await AntennaNotes.count({
antennaId: antenna.id,
read: false
read: false,
});
if (count === 0) {

View File

@ -12,7 +12,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
//#region ミュートしているなら無視
// TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする
const mute = await Mutings.find({
muterId: userId
muterId: userId,
});
if (mute.map(m => m.muteeId).includes(note.userId)) return;
//#endregion

View File

@ -5,6 +5,6 @@ import { Note } from '@/models/entities/note';
export default async (me: User['id'], note: Note) => {
await NoteWatchings.delete({
noteId: note.id,
userId: me
userId: me,
});
};

View File

@ -15,6 +15,6 @@ export default async (me: User['id'], note: Note) => {
createdAt: new Date(),
noteId: note.id,
userId: me,
noteUserId: note.userId
noteUserId: note.userId,
} as NoteWatching);
};

View File

@ -19,7 +19,7 @@ export default async function(userId: string, type: notificationType, body: noti
// Fetch
const subscriptions = await SwSubscriptions.find({
userId: userId
userId: userId,
});
for (const subscription of subscriptions) {
@ -27,14 +27,14 @@ export default async function(userId: string, type: notificationType, body: noti
endpoint: subscription.endpoint,
keys: {
auth: subscription.auth,
p256dh: subscription.publickey
}
p256dh: subscription.publickey,
},
};
push.sendNotification(pushSubscription, JSON.stringify({
type, body
type, body,
}), {
proxy: config.proxy
proxy: config.proxy,
}).catch((err: any) => {
//swLogger.info(err.statusCode);
//swLogger.info(err.headers);
@ -45,7 +45,7 @@ export default async function(userId: string, type: notificationType, body: noti
userId: userId,
endpoint: subscription.endpoint,
auth: subscription.auth,
publickey: subscription.publickey
publickey: subscription.publickey,
});
}
});

View File

@ -12,7 +12,7 @@ const ACTOR_USERNAME = 'relay.actor' as const;
export async function getRelayActor(): Promise<ILocalUser> {
const user = await Users.findOne({
host: null,
username: ACTOR_USERNAME
username: ACTOR_USERNAME,
});
if (user) return user as ILocalUser;
@ -25,7 +25,7 @@ export async function addRelay(inbox: string) {
const relay = await Relays.save({
id: genId(),
inbox,
status: 'requesting'
status: 'requesting',
});
const relayActor = await getRelayActor();
@ -38,7 +38,7 @@ export async function addRelay(inbox: string) {
export async function removeRelay(inbox: string) {
const relay = await Relays.findOne({
inbox
inbox,
});
if (relay == null) {
@ -61,7 +61,7 @@ export async function listRelay() {
export async function relayAccepted(id: string) {
const result = await Relays.update(id, {
status: 'accepted'
status: 'accepted',
});
return JSON.stringify(result);
@ -69,7 +69,7 @@ export async function relayAccepted(id: string) {
export async function relayRejected(id: string) {
const result = await Relays.update(id, {
status: 'rejected'
status: 'rejected',
});
return JSON.stringify(result);
@ -79,7 +79,7 @@ export async function deliverToRelays(user: { id: User['id']; host: null; }, act
if (activity == null) return;
const relays = await Relays.find({
status: 'accepted'
status: 'accepted',
});
if (relays.length === 0) return;

View File

@ -23,7 +23,7 @@ import {
ReversiGameStreamTypes,
ReversiStreamTypes,
UserListStreamTypes,
UserStreamTypes
UserStreamTypes,
} from '@/server/api/stream/types';
import { Packed } from '@/misc/schema';
@ -35,7 +35,7 @@ class Publisher {
redisClient.publish(config.host, JSON.stringify({
channel: channel,
message: message
message: message,
}));
};
@ -62,7 +62,7 @@ class Publisher {
public publishNoteStream = <K extends keyof NoteStreamTypes>(noteId: Note['id'], type: K, value?: NoteStreamTypes[K]): void => {
this.publish(`noteStream:${noteId}`, type, {
id: noteId,
body: value
body: value,
});
};

View File

@ -16,9 +16,9 @@ export async function doPostSuspend(user: { id: User['id']; host: User['host'] }
const followings = await Followings.find({
where: [
{ followerSharedInbox: Not(IsNull()) },
{ followeeSharedInbox: Not(IsNull()) }
{ followeeSharedInbox: Not(IsNull()) },
],
select: ['followerSharedInbox', 'followeeSharedInbox']
select: ['followerSharedInbox', 'followeeSharedInbox'],
});
const inboxes = followings.map(x => x.followerSharedInbox || x.followeeSharedInbox);

View File

@ -17,9 +17,9 @@ export async function doPostUnsuspend(user: User) {
const followings = await Followings.find({
where: [
{ followerSharedInbox: Not(IsNull()) },
{ followeeSharedInbox: Not(IsNull()) }
{ followeeSharedInbox: Not(IsNull()) },
],
select: ['followerSharedInbox', 'followeeSharedInbox']
select: ['followerSharedInbox', 'followeeSharedInbox'],
});
const inboxes = followings.map(x => x.followerSharedInbox || x.followeeSharedInbox);

View File

@ -12,7 +12,7 @@ export async function pushUserToUserList(target: User, list: UserList) {
id: genId(),
createdAt: new Date(),
userId: target.id,
userListId: list.id
userListId: list.id,
} as UserListJoining);
publishUserListStream(list.id, 'userAdded', await Users.pack(target));