summaryrefslogtreecommitdiff
path: root/src/server/api
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-03-21 13:36:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-03-21 13:36:41 +0900
commit6fb7721798657cf842556fb63f116316365efa74 (patch)
tree6917342553156b6483b899eafc66ef8f040b8352 /src/server/api
parentUpdate CHANGELOG.md (diff)
parent12.22.0 (diff)
downloadmisskey-6fb7721798657cf842556fb63f116316365efa74.tar.gz
misskey-6fb7721798657cf842556fb63f116316365efa74.tar.bz2
misskey-6fb7721798657cf842556fb63f116316365efa74.zip
Merge branch 'develop'
Diffstat (limited to 'src/server/api')
-rw-r--r--src/server/api/common/signin.ts8
-rw-r--r--src/server/api/endpoints/antennas/create.ts4
-rw-r--r--src/server/api/endpoints/antennas/update.ts4
-rw-r--r--src/server/api/endpoints/charts/active-users.ts7
-rw-r--r--src/server/api/endpoints/charts/drive.ts7
-rw-r--r--src/server/api/endpoints/charts/federation.ts7
-rw-r--r--src/server/api/endpoints/charts/hashtag.ts7
-rw-r--r--src/server/api/endpoints/charts/instance.ts7
-rw-r--r--src/server/api/endpoints/charts/network.ts7
-rw-r--r--src/server/api/endpoints/charts/notes.ts7
-rw-r--r--src/server/api/endpoints/charts/user/drive.ts7
-rw-r--r--src/server/api/endpoints/charts/user/following.ts7
-rw-r--r--src/server/api/endpoints/charts/user/notes.ts7
-rw-r--r--src/server/api/endpoints/charts/user/reactions.ts7
-rw-r--r--src/server/api/endpoints/charts/users.ts7
-rw-r--r--src/server/api/endpoints/stats.ts6
-rw-r--r--src/server/api/endpoints/users/search-by-username-and-host.ts7
-rw-r--r--src/server/api/endpoints/users/search.ts2
-rw-r--r--src/server/api/service/discord.ts15
-rw-r--r--src/server/api/service/github.ts14
-rw-r--r--src/server/api/service/twitter.ts14
-rw-r--r--src/server/api/stream/channels/main.ts11
22 files changed, 109 insertions, 60 deletions
diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts
index aa2786f8fc..50f79f1919 100644
--- a/src/server/api/common/signin.ts
+++ b/src/server/api/common/signin.ts
@@ -9,16 +9,12 @@ import { publishMainStream } from '../../../services/stream';
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
if (redirect) {
//#region Cookie
- const expires = 1000 * 60 * 60 * 24 * 365; // One Year
- ctx.cookies.set('i', user.token, {
+ ctx.cookies.set('igi', user.token, {
path: '/',
- domain: config.hostname,
// SEE: https://github.com/koajs/koa/issues/974
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
secure: config.url.startsWith('https'),
- httpOnly: false,
- expires: new Date(Date.now() + expires),
- maxAge: expires
+ httpOnly: false
});
//#endregion
diff --git a/src/server/api/endpoints/antennas/create.ts b/src/server/api/endpoints/antennas/create.ts
index f11b198f86..bc79385260 100644
--- a/src/server/api/endpoints/antennas/create.ts
+++ b/src/server/api/endpoints/antennas/create.ts
@@ -82,7 +82,7 @@ export default define(meta, async (ps, user) => {
id: ps.userListId,
userId: user.id,
});
-
+
if (userList == null) {
throw new ApiError(meta.errors.noSuchUserList);
}
@@ -91,7 +91,7 @@ export default define(meta, async (ps, user) => {
userGroupId: ps.userGroupId,
userId: user.id,
});
-
+
if (userGroupJoining == null) {
throw new ApiError(meta.errors.noSuchUserGroup);
}
diff --git a/src/server/api/endpoints/antennas/update.ts b/src/server/api/endpoints/antennas/update.ts
index ab4ce57937..b329e86ade 100644
--- a/src/server/api/endpoints/antennas/update.ts
+++ b/src/server/api/endpoints/antennas/update.ts
@@ -101,7 +101,7 @@ export default define(meta, async (ps, user) => {
id: ps.userListId,
userId: user.id,
});
-
+
if (userList == null) {
throw new ApiError(meta.errors.noSuchUserList);
}
@@ -110,7 +110,7 @@ export default define(meta, async (ps, user) => {
userGroupId: ps.userGroupId,
userId: user.id,
});
-
+
if (userGroupJoining == null) {
throw new ApiError(meta.errors.noSuchUserGroup);
}
diff --git a/src/server/api/endpoints/charts/active-users.ts b/src/server/api/endpoints/charts/active-users.ts
index 59bb1db109..df427ff4b7 100644
--- a/src/server/api/endpoints/charts/active-users.ts
+++ b/src/server/api/endpoints/charts/active-users.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(activeUsersChart.schema),
};
export default define(meta, async (ps) => {
- return await activeUsersChart.getChart(ps.span as any, ps.limit!);
+ return await activeUsersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/drive.ts b/src/server/api/endpoints/charts/drive.ts
index 5c26fe719a..e1f279fa0a 100644
--- a/src/server/api/endpoints/charts/drive.ts
+++ b/src/server/api/endpoints/charts/drive.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(driveChart.schema),
};
export default define(meta, async (ps) => {
- return await driveChart.getChart(ps.span as any, ps.limit!);
+ return await driveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/federation.ts b/src/server/api/endpoints/charts/federation.ts
index ebd60cc24b..581e42f307 100644
--- a/src/server/api/endpoints/charts/federation.ts
+++ b/src/server/api/endpoints/charts/federation.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(federationChart.schema),
};
export default define(meta, async (ps) => {
- return await federationChart.getChart(ps.span as any, ps.limit!);
+ return await federationChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/hashtag.ts b/src/server/api/endpoints/charts/hashtag.ts
index 8d14430137..1aa5c86b35 100644
--- a/src/server/api/endpoints/charts/hashtag.ts
+++ b/src/server/api/endpoints/charts/hashtag.ts
@@ -26,6 +26,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
tag: {
validator: $.str,
desc: {
@@ -38,5 +43,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.tag);
+ return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.tag);
});
diff --git a/src/server/api/endpoints/charts/instance.ts b/src/server/api/endpoints/charts/instance.ts
index 4c26b7614c..f0f85ed71a 100644
--- a/src/server/api/endpoints/charts/instance.ts
+++ b/src/server/api/endpoints/charts/instance.ts
@@ -26,6 +26,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
host: {
validator: $.str,
desc: {
@@ -39,5 +44,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await instanceChart.getChart(ps.span as any, ps.limit!, ps.host);
+ return await instanceChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.host);
});
diff --git a/src/server/api/endpoints/charts/network.ts b/src/server/api/endpoints/charts/network.ts
index 162c0c9ecd..d1337681a9 100644
--- a/src/server/api/endpoints/charts/network.ts
+++ b/src/server/api/endpoints/charts/network.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(networkChart.schema),
};
export default define(meta, async (ps) => {
- return await networkChart.getChart(ps.span as any, ps.limit!);
+ return await networkChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/notes.ts b/src/server/api/endpoints/charts/notes.ts
index c25f46f543..74aa48b36e 100644
--- a/src/server/api/endpoints/charts/notes.ts
+++ b/src/server/api/endpoints/charts/notes.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(notesChart.schema),
};
export default define(meta, async (ps) => {
- return await notesChart.getChart(ps.span as any, ps.limit!);
+ return await notesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/user/drive.ts b/src/server/api/endpoints/charts/user/drive.ts
index 6bfa427403..5aae5bd757 100644
--- a/src/server/api/endpoints/charts/user/drive.ts
+++ b/src/server/api/endpoints/charts/user/drive.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/following.ts b/src/server/api/endpoints/charts/user/following.ts
index 0da995e2ec..9d772c39c9 100644
--- a/src/server/api/endpoints/charts/user/following.ts
+++ b/src/server/api/endpoints/charts/user/following.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/notes.ts b/src/server/api/endpoints/charts/user/notes.ts
index 754ade1228..8de7c0c3e4 100644
--- a/src/server/api/endpoints/charts/user/notes.ts
+++ b/src/server/api/endpoints/charts/user/notes.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/reactions.ts b/src/server/api/endpoints/charts/user/reactions.ts
index f3344c6648..4c37305fc3 100644
--- a/src/server/api/endpoints/charts/user/reactions.ts
+++ b/src/server/api/endpoints/charts/user/reactions.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/users.ts b/src/server/api/endpoints/charts/users.ts
index 0d7fb7b951..18eec384a6 100644
--- a/src/server/api/endpoints/charts/users.ts
+++ b/src/server/api/endpoints/charts/users.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(usersChart.schema),
};
export default define(meta, async (ps) => {
- return await usersChart.getChart(ps.span as any, ps.limit!);
+ return await usersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts
index 5bc224450b..dab05c1675 100644
--- a/src/server/api/endpoints/stats.ts
+++ b/src/server/api/endpoints/stats.ts
@@ -60,9 +60,9 @@ export default define(meta, async () => {
Notes.count({ where: { userHost: null }, cache: 3600000 }),
Users.count({ cache: 3600000 }),
Users.count({ where: { host: null }, cache: 3600000 }),
- federationChart.getChart('hour', 1).then(chart => chart.instance.total[0]),
- driveChart.getChart('hour', 1).then(chart => chart.local.totalSize[0]),
- driveChart.getChart('hour', 1).then(chart => chart.remote.totalSize[0]),
+ federationChart.getChart('hour', 1, null).then(chart => chart.instance.total[0]),
+ driveChart.getChart('hour', 1, null).then(chart => chart.local.totalSize[0]),
+ driveChart.getChart('hour', 1, null).then(chart => chart.remote.totalSize[0]),
]);
return {
diff --git a/src/server/api/endpoints/users/search-by-username-and-host.ts b/src/server/api/endpoints/users/search-by-username-and-host.ts
index 81ff19ff6f..bc68f44094 100644
--- a/src/server/api/endpoints/users/search-by-username-and-host.ts
+++ b/src/server/api/endpoints/users/search-by-username-and-host.ts
@@ -1,7 +1,6 @@
import $ from 'cafy';
import define from '../../define';
import { Users } from '../../../../models';
-import { User } from '../../../../models/entities/user';
export const meta = {
desc: {
@@ -73,14 +72,17 @@ export default define(meta, async (ps, me) => {
q.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
}
+ q.orderBy('user.updatedAt', 'DESC');
+
const users = await q.take(ps.limit!).skip(ps.offset).getMany();
return await Users.packMany(users, me, { detail: ps.detail });
- } else {
+ } else if (ps.username) {
let users = await Users.createQueryBuilder('user')
.where('user.host IS NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit!)
.skip(ps.offset)
.getMany();
@@ -90,6 +92,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NOT NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit! - users.length)
.getMany();
diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts
index dbeb6eb6af..c01f355d8c 100644
--- a/src/server/api/endpoints/users/search.ts
+++ b/src/server/api/endpoints/users/search.ts
@@ -74,6 +74,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit!)
.skip(ps.offset)
.getMany();
@@ -83,6 +84,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NOT NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit! - users.length)
.getMany();
diff --git a/src/server/api/service/discord.ts b/src/server/api/service/discord.ts
index f9f3026aa8..c2bb02453b 100644
--- a/src/server/api/service/discord.ts
+++ b/src/server/api/service/discord.ts
@@ -13,7 +13,7 @@ import { ILocalUser } from '../../../models/entities/user';
import { ensure } from '../../../prelude/ensure';
function getUserToken(ctx: Koa.Context) {
- return ((ctx.headers['cookie'] || '').match(/i=(\w+)/) || [null, null])[1];
+ return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
}
function compareOrigin(ctx: Koa.Context) {
@@ -113,14 +113,10 @@ router.get('/signin/discord', async ctx => {
response_type: 'code'
};
- const expires = 1000 * 60 * 60; // 1h
- ctx.cookies.set('signin_with_discord_session_id', sessid, {
+ ctx.cookies.set('signin_with_discord_sid', sessid, {
path: '/',
- domain: config.host,
secure: config.url.startsWith('https'),
- httpOnly: true,
- expires: new Date(Date.now() + expires),
- maxAge: expires
+ httpOnly: true
});
redis.set(sessid, JSON.stringify(params));
@@ -135,7 +131,7 @@ router.get('/dc/cb', async ctx => {
const oauth2 = await getOAuth2();
if (!userToken) {
- const sessid = ctx.cookies.get('signin_with_discord_session_id');
+ const sessid = ctx.cookies.get('signin_with_discord_sid');
if (!sessid) {
ctx.throw(400, 'invalid session');
@@ -199,7 +195,7 @@ router.get('/dc/cb', async ctx => {
}
const profile = await UserProfiles.createQueryBuilder()
- .where('"integrations"->"discord"->"id" = :id', { id: id })
+ .where(`"integrations"->'discord'->>'id' = :id`, { id: id })
.andWhere('"userHost" IS NULL')
.getOne();
@@ -212,6 +208,7 @@ router.get('/dc/cb', async ctx => {
integrations: {
...profile.integrations,
discord: {
+ id: id,
accessToken: accessToken,
refreshToken: refreshToken,
expiresDate: expiresDate,
diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts
index ec9cce7ad8..e36c43ee38 100644
--- a/src/server/api/service/github.ts
+++ b/src/server/api/service/github.ts
@@ -13,7 +13,7 @@ import { ILocalUser } from '../../../models/entities/user';
import { ensure } from '../../../prelude/ensure';
function getUserToken(ctx: Koa.Context) {
- return ((ctx.headers['cookie'] || '').match(/i=(\w+)/) || [null, null])[1];
+ return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
}
function compareOrigin(ctx: Koa.Context) {
@@ -111,14 +111,10 @@ router.get('/signin/github', async ctx => {
state: uuid()
};
- const expires = 1000 * 60 * 60; // 1h
- ctx.cookies.set('signin_with_github_session_id', sessid, {
+ ctx.cookies.set('signin_with_github_sid', sessid, {
path: '/',
- domain: config.host,
secure: config.url.startsWith('https'),
- httpOnly: true,
- expires: new Date(Date.now() + expires),
- maxAge: expires
+ httpOnly: true
});
redis.set(sessid, JSON.stringify(params));
@@ -133,7 +129,7 @@ router.get('/gh/cb', async ctx => {
const oauth2 = await getOath2();
if (!userToken) {
- const sessid = ctx.cookies.get('signin_with_github_session_id');
+ const sessid = ctx.cookies.get('signin_with_github_sid');
if (!sessid) {
ctx.throw(400, 'invalid session');
@@ -192,7 +188,7 @@ router.get('/gh/cb', async ctx => {
}
const link = await UserProfiles.createQueryBuilder()
- .where('"integrations"->"github"->"id" = :id', { id: id })
+ .where(`"integrations"->'github'->>'id' = :id`, { id: id })
.andWhere('"userHost" IS NULL')
.getOne();
diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts
index 881915b58f..000eb57c1b 100644
--- a/src/server/api/service/twitter.ts
+++ b/src/server/api/service/twitter.ts
@@ -12,7 +12,7 @@ import { ILocalUser } from '../../../models/entities/user';
import { ensure } from '../../../prelude/ensure';
function getUserToken(ctx: Koa.Context) {
- return ((ctx.headers['cookie'] || '').match(/i=(\w+)/) || [null, null])[1];
+ return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
}
function compareOrigin(ctx: Koa.Context) {
@@ -102,14 +102,10 @@ router.get('/signin/twitter', async ctx => {
redis.set(sessid, JSON.stringify(twCtx));
- const expires = 1000 * 60 * 60; // 1h
- ctx.cookies.set('signin_with_twitter_session_id', sessid, {
+ ctx.cookies.set('signin_with_twitter_sid', sessid, {
path: '/',
- domain: config.host,
secure: config.url.startsWith('https'),
- httpOnly: true,
- expires: new Date(Date.now() + expires),
- maxAge: expires
+ httpOnly: true
});
ctx.redirect(twCtx.url);
@@ -121,7 +117,7 @@ router.get('/tw/cb', async ctx => {
const twAuth = await getTwAuth();
if (userToken == null) {
- const sessid = ctx.cookies.get('signin_with_twitter_session_id');
+ const sessid = ctx.cookies.get('signin_with_twitter_sid');
if (sessid == null) {
ctx.throw(400, 'invalid session');
@@ -139,7 +135,7 @@ router.get('/tw/cb', async ctx => {
const result = await twAuth!.done(JSON.parse(twCtx), ctx.query.oauth_verifier);
const link = await UserProfiles.createQueryBuilder()
- .where('"integrations"->"twitter"->"userId" = :id', { id: result.userId })
+ .where(`"integrations"->'twitter'->>'userId' = :id`, { id: result.userId })
.andWhere('"userHost" IS NULL')
.getOne();
diff --git a/src/server/api/stream/channels/main.ts b/src/server/api/stream/channels/main.ts
index 8cd4fcac99..22e664baca 100644
--- a/src/server/api/stream/channels/main.ts
+++ b/src/server/api/stream/channels/main.ts
@@ -1,6 +1,6 @@
import autobind from 'autobind-decorator';
import Channel from '../channel';
-import { Mutings, Notes } from '../../../../models';
+import { Notes } from '../../../../models';
export default class extends Channel {
public readonly chName = 'main';
@@ -9,15 +9,14 @@ export default class extends Channel {
@autobind
public async init(params: any) {
- const mute = await Mutings.find({ muterId: this.user!.id });
-
// Subscribe main stream channel
this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
- let { type, body } = data;
+ const { type } = data;
+ let { body } = data;
switch (type) {
case 'notification': {
- if (mute.map(m => m.muteeId).includes(body.userId)) return;
+ if (this.muting.includes(body.userId)) return;
if (body.note && body.note.isHidden) {
body.note = await Notes.pack(body.note.id, this.user, {
detail: true
@@ -26,7 +25,7 @@ export default class extends Channel {
break;
}
case 'mention': {
- if (mute.map(m => m.muteeId).includes(body.userId)) return;
+ if (this.muting.includes(body.userId)) return;
if (body.isHidden) {
body = await Notes.pack(body.id, this.user, {
detail: true