diff --git a/package.json b/package.json index c41601ab58..9ce6e2a16b 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "constantinople": "^4.0.1", "core-js": "^3.6.5", "gulp/gulp-cli/yargs/yargs-parser": "5.0.0-security.0", - "lodash": "^4.17.19", + "lodash": "^4.17.20", "mocha/serialize-javascript": "^3.1.0" }, "dependencies": { diff --git a/src/client/pages/channels.vue b/src/client/pages/channels.vue index 804232f2f5..bd44ea5aa0 100644 --- a/src/client/pages/channels.vue +++ b/src/client/pages/channels.vue @@ -43,7 +43,7 @@ export default defineComponent({ tab: 'featured', featuredPagination: { endpoint: 'channels/featured', - limit: 5, + noPaging: true, }, followingPagination: { endpoint: 'channels/followed', diff --git a/src/server/api/endpoints/channels/followed.ts b/src/server/api/endpoints/channels/followed.ts index 05c2ec6a75..bd37d420f6 100644 --- a/src/server/api/endpoints/channels/followed.ts +++ b/src/server/api/endpoints/channels/followed.ts @@ -1,5 +1,8 @@ +import $ from 'cafy'; +import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { Channels, ChannelFollowings } from '../../../../models'; +import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['channels', 'account'], @@ -8,6 +11,21 @@ export const meta = { kind: 'read:channels', + params: { + sinceId: { + validator: $.optional.type(ID), + }, + + untilId: { + validator: $.optional.type(ID), + }, + + limit: { + validator: $.optional.num.range(1, 100), + default: 5 + }, + }, + res: { type: 'array' as const, optional: false as const, nullable: false as const, @@ -20,9 +38,12 @@ export const meta = { }; export default define(meta, async (ps, me) => { - const followings = await ChannelFollowings.find({ - followerId: me.id, - }); + const query = makePaginationQuery(ChannelFollowings.createQueryBuilder(), ps.sinceId, ps.untilId) + .andWhere({ followerId: me.id }); + + const followings = await query + .take(ps.limit!) + .getMany(); return await Promise.all(followings.map(x => Channels.pack(x.followeeId, me))); }); diff --git a/src/server/api/endpoints/channels/owned.ts b/src/server/api/endpoints/channels/owned.ts index 9e563c0ac5..1a7e04640d 100644 --- a/src/server/api/endpoints/channels/owned.ts +++ b/src/server/api/endpoints/channels/owned.ts @@ -1,5 +1,8 @@ +import $ from 'cafy'; +import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { Channels } from '../../../../models'; +import { makePaginationQuery } from '../../common/make-pagination-query'; export const meta = { tags: ['channels', 'account'], @@ -8,6 +11,21 @@ export const meta = { kind: 'read:channels', + params: { + sinceId: { + validator: $.optional.type(ID), + }, + + untilId: { + validator: $.optional.type(ID), + }, + + limit: { + validator: $.optional.num.range(1, 100), + default: 5 + }, + }, + res: { type: 'array' as const, optional: false as const, nullable: false as const, @@ -20,9 +38,12 @@ export const meta = { }; export default define(meta, async (ps, me) => { - const channels = await Channels.find({ - userId: me.id, - }); + const query = makePaginationQuery(Channels.createQueryBuilder(), ps.sinceId, ps.untilId) + .andWhere({ userId: me.id }); + + const channels = await query + .take(ps.limit!) + .getMany(); return await Promise.all(channels.map(x => Channels.pack(x, me))); }); diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index f011a6751f..f46139aa23 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -99,6 +99,8 @@ export default define(meta, async (ps, me) => { } }); + const proxyAccount = instance.proxyAccountId ? await Users.pack(instance.proxyAccountId).catch(() => null) : null; + const response: any = { maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, @@ -143,6 +145,8 @@ export default define(meta, async (ps, me) => { enableDiscordIntegration: instance.enableDiscordIntegration, enableServiceWorker: instance.enableServiceWorker, + + proxyAccountName: proxyAccount ? proxyAccount.username : null, }; if (ps.detail) { diff --git a/src/server/nodeinfo.ts b/src/server/nodeinfo.ts index b0de850dd0..5c51137c92 100644 --- a/src/server/nodeinfo.ts +++ b/src/server/nodeinfo.ts @@ -1,6 +1,7 @@ import * as Router from '@koa/router'; import config from '../config'; import { fetchMeta } from '../misc/fetch-meta'; +import { Users } from '../models'; // import User from '../models/user'; // import Note from '../models/note'; @@ -34,6 +35,8 @@ const nodeinfo2 = async () => { // Note.count({ '_user.host': null, replyId: { $ne: null } }) ]); + const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null; + return { software: { name: 'misskey', @@ -72,7 +75,8 @@ const nodeinfo2 = async () => { enableGithubIntegration: meta.enableGithubIntegration, enableDiscordIntegration: meta.enableDiscordIntegration, enableEmail: meta.enableEmail, - enableServiceWorker: meta.enableServiceWorker + enableServiceWorker: meta.enableServiceWorker, + proxyAccountName: proxyAccount ? proxyAccount.username : null, } }; }; diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 18cd102eba..507ddac3ce 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -326,6 +326,9 @@ router.get('/info', async ctx => { const emojis = await Emojis.find({ where: { host: null } }); + + const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null; + await ctx.render('info', { version: config.version, machine: os.hostname(), @@ -339,6 +342,7 @@ router.get('/info', async ctx => { }, emojis: emojis, meta: meta, + proxyAccountName: proxyAccount ? proxyAccount.username : null, originalUsersCount: await Users.count({ host: null }), originalNotesCount: await Notes.count({ userHost: null }) }); diff --git a/src/server/web/views/info.pug b/src/server/web/views/info.pug index 4553d2e2b9..eed69fc99e 100644 --- a/src/server/web/views/info.pug +++ b/src/server/web/views/info.pug @@ -79,6 +79,9 @@ html td = meta.maintainerName | <#{meta.maintainerEmail}> + tr + th Proxy account name + td= proxyAccountName || '(none)' tr th System td= os diff --git a/src/services/create-notification.ts b/src/services/create-notification.ts index 4e713e3804..7471c349ee 100644 --- a/src/services/create-notification.ts +++ b/src/services/create-notification.ts @@ -16,7 +16,7 @@ export async function createNotification( const profile = await UserProfiles.findOne({ userId: notifieeId }); - const isMuted = !profile?.includingNotificationTypes?.includes(type); + const isMuted = !(profile?.includingNotificationTypes == null || profile?.includingNotificationTypes.includes(type)); // Create notification const notification = await Notifications.save({ diff --git a/src/services/note/create.ts b/src/services/note/create.ts index a530b86f55..c8e3db540d 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -135,6 +135,7 @@ export default async (user: User, data: Option, silent = false) => new Promise