Skip to content

Commit

Permalink
Merge tag '10.102.692-m544' into custom/atsuchan
Browse files Browse the repository at this point in the history
10.102.692-m544
  • Loading branch information
atsu1125 committed Mar 11, 2024
2 parents 146f78d + dcdad28 commit f8704cf
Show file tree
Hide file tree
Showing 25 changed files with 80 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "misskey",
"author": "mei23 <[email protected]>",
"version": "10.102.691-m544",
"version": "10.102.692-m544",
"codename": "m544",
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions src/client/app/admin/views/federation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export default defineComponent({
this.$root.api('admin/delete-instance-users', {
host: this.instance.host,
limit: 1000,
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
}).catch((e: any) => {
this.$root.dialog({
type: 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export default Vue.extend({
computed: {
_mutedWords: {
get() { return this.$store.state.settings.mutedWords; },
set(value) { this.$store.dispatch('settings/set', { key: 'mutedWords', value }); }
set(value) {
this.$store.dispatch('settings/set', { key: 'mutedWords', value });
this.$root.dialog({ type: 'success', splash: true });
}
},
},
Expand Down
31 changes: 9 additions & 22 deletions src/queue/processors/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const tryProcessInbox = async (data: InboxJobData, ctx?: ApContext): Prom
const activity = data.activity;

const resolver = ctx?.resolver || new Resolver();
const dbResolver = ctx?.dbResolver || new DbResolver();

//#region Log
logger.debug(inspect(signature));
Expand All @@ -58,19 +57,14 @@ export const tryProcessInbox = async (data: InboxJobData, ctx?: ApContext): Prom
//#region resolve http-signature signer
let user: IRemoteUser | null;

// keyIdを元にDBから取得
user = await dbResolver.getRemoteUserFromKeyId(signature.keyId);

// || activity.actorを元にDBから取得 || activity.actorを元にリモートから取得
if (user == null) {
try {
user = await resolvePerson(getApId(activity.actor), undefined, resolver, isDelete(activity) || isUndo(activity)) as IRemoteUser;
} catch (e) {
if (e instanceof StatusError && e.isPermanentError) {
return `skip: Ignored actor ${activity.actor} - ${e.statusCode}`;
}
throw `Error in actor ${activity.actor} - ${e.statusCode || e}`;
// activity.actorを元にDBから取得 || activity.actorを元にリモートから取得
try {
user = await resolvePerson(getApId(activity.actor), undefined, resolver, isDelete(activity) || isUndo(activity)) as IRemoteUser;
} catch (e) {
if (e instanceof StatusError && e.isPermanentError) {
return `skip: Ignored actor ${activity.actor} - ${e.statusCode}`;
}
throw `Error in actor ${activity.actor} - ${e.statusCode || e}`;
}

// http-signature signer がわからなければ終了
Expand All @@ -95,20 +89,13 @@ export const tryProcessInbox = async (data: InboxJobData, ctx?: ApContext): Prom
// また、http-signatureのsignerは、activity.actorと一致する必要がある
if (!httpSignatureValidated || user.uri !== activity.actor) {
// でもLD-Signatureがありそうならそっちも見る
if (!config.ignoreApForwarded && activity.signature) {
if (!config.ignoreApForwarded && activity.signature?.creator) {
if (activity.signature.type !== 'RsaSignature2017') {
return `skip: unsupported LD-signature type ${activity.signature.type}`;
}

// activity.signature.creator: https://example.oom/users/user#main-key
// みたいになっててUserを引っ張れば公開キーも入ることを期待する
if (activity.signature.creator) {
const candicate = activity.signature.creator.replace(/#.*/, '');
await resolvePerson(candicate).catch(() => null);
}
user = await resolvePerson(activity.signature.creator.replace(/#.*/, '')).catch(() => null) as IRemoteUser | null;

// keyIdからLD-Signatureのユーザーを取得
user = await dbResolver.getRemoteUserFromKeyId(activity.signature.creator);
if (user == null) {
return `skip: LD-Signatureのユーザーが取得できませんでした`;
}
Expand Down
10 changes: 9 additions & 1 deletion src/remote/activitypub/db-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Note, { INote } from '../../models/note';
import { IObject, getApId } from './type';
import * as escapeRegexp from 'escape-regexp';
import MessagingMessage, { IMessagingMessage } from '../../models/messaging-message';
import { toDbHost } from '../../misc/convert-host';

export default class DbResolver {
constructor() {
Expand Down Expand Up @@ -54,8 +55,15 @@ export default class DbResolver {
}

public async getRemoteUserFromKeyId(keyId: string): Promise<IRemoteUser | null> {
let u: URL | null = null;
try {
u = new URL(keyId);
} catch {
return null;
}

const user = await User.findOne({
host: { $ne: null },
host: toDbHost(u.hostname),
'publicKey.id': keyId,
deletedAt: { $exists: false }
}) as IRemoteUser;
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/blocking/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Blocking from '../../../../models/blocking';
import create from '../../../../services/blocking/create';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';
import deleteFollowing from '../../../../services/following/delete';

export const meta = {
Expand Down Expand Up @@ -70,7 +70,7 @@ export default define(meta, async (ps, user) => {

// Get blockee
const blockee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/blocking/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Blocking from '../../../../models/blocking';
import deleteBlocking from '../../../../services/blocking/delete';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';

export const meta = {
stability: 'stable',
Expand Down Expand Up @@ -79,7 +79,7 @@ export default define(meta, async (ps, user) => {

// Get blockee
const blockee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') {
if (e instanceof GetterError && e.type === 'noSuchUser') {
return null;
}
throw e;
Expand Down
12 changes: 8 additions & 4 deletions src/server/api/endpoints/following/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import Following from '../../../../models/following';
import create from '../../../../services/following/create';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';
import config from '../../../../config';
import { FollowingError } from '../../../../services/following/following-error';

export const meta = {
stability: 'stable',
Expand Down Expand Up @@ -88,7 +89,7 @@ export default define(meta, async (ps, user) => {

// Get followee
const followee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand All @@ -115,8 +116,11 @@ export default define(meta, async (ps, user) => {
try {
await create(follower, followee);
} catch (e) {
if (e.id === '710e8fb0-b8c3-4922-be49-d5d93d8e6a6e') throw new ApiError(meta.errors.blocking);
if (e.id === '3338392a-f764-498d-8855-db939dcf8c48') throw new ApiError(meta.errors.blocked);
if (e instanceof FollowingError) {
if (e.type === 'blocking') throw new ApiError(meta.errors.blocking);
if (e.type === 'blocked') throw new ApiError(meta.errors.blocked);

}
throw e;
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/following/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Following from '../../../../models/following';
import deleteFollowing from '../../../../services/following/delete';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';

export const meta = {
stability: 'stable',
Expand Down Expand Up @@ -69,7 +69,7 @@ export default define(meta, async (ps, user) => {

// Get followee
const followee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/following/invalidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Following from '../../../../models/following';
import deleteFollowing from '../../../../services/following/delete';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';

export const meta = {
stability: 'stable',
Expand Down Expand Up @@ -69,7 +69,7 @@ export default define(meta, async (ps, user) => {

// Get follower
const follower = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
9 changes: 6 additions & 3 deletions src/server/api/endpoints/following/requests/cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import cancelFollowRequest from '../../../../../services/following/requests/canc
import { pack } from '../../../../../models/user';
import define from '../../../define';
import { ApiError } from '../../../error';
import { getUser } from '../../../common/getters';
import { GetterError, getUser } from '../../../common/getters';
import { FollowingError } from '../../../../../services/following/following-error';

export const meta = {
desc: {
Expand Down Expand Up @@ -47,14 +48,16 @@ export const meta = {
export default define(meta, async (ps, user) => {
// Fetch followee
const followee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

try {
await cancelFollowRequest(followee, user);
} catch (e) {
if (e.id === '17447091-ce07-46dd-b331-c1fd4f15b1e7') throw new ApiError(meta.errors.followRequestNotFound);
if (e instanceof FollowingError) {
if (e.type === 'followRequestNotFound') throw new ApiError(meta.errors.followRequestNotFound);
}
throw e;
}

Expand Down
5 changes: 2 additions & 3 deletions src/server/api/endpoints/following/requests/reject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ID, { transform } from '../../../../../misc/cafy-id';
import rejectFollowRequest from '../../../../../services/following/requests/reject';
import define from '../../../define';
import { ApiError } from '../../../error';
import { getUser } from '../../../common/getters';
import { GetterError, getUser } from '../../../common/getters';

export const meta = {
desc: {
Expand Down Expand Up @@ -40,8 +40,7 @@ export const meta = {
export default define(meta, async (ps, user) => {
// Fetch follower
const follower = await getUser(ps.userId!).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
throw e;
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser); throw e;
});

await rejectFollowRequest(user, follower);
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/games/reversi/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { publishMainStream, publishReversiStream } from '../../../../../services
import { eighteight } from '../../../../../games/reversi/maps';
import define from '../../../define';
import { ApiError } from '../../../error';
import { getUser } from '../../../common/getters';
import { GetterError, getUser } from '../../../common/getters';

export const meta = {
tags: ['games'],
Expand Down Expand Up @@ -88,7 +88,7 @@ export default define(meta, async (ps, user) => {
} else {
// Fetch child
const child = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
6 changes: 4 additions & 2 deletions src/server/api/endpoints/i/unpin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'cafy';
import ID, { transform } from '../../../../misc/cafy-id';
import User, { pack } from '../../../../models/user';
import { removePinned } from '../../../../services/i/pin';
import { PinError, removePinned } from '../../../../services/i/pin';
import define from '../../define';
import { ApiError } from '../../error';
import { publishMainStream } from '../../../../services/stream';
Expand Down Expand Up @@ -41,7 +41,9 @@ export const meta = {

export default define(meta, async (ps, user) => {
await removePinned(user, ps.noteId).catch(e => {
if (e.id === 'b302d4cf-c050-400a-bbb3-be208681f40c') throw new ApiError(meta.errors.noSuchNote);
if (e instanceof PinError) {
if (e.type === 'noSuchNote') throw new ApiError(meta.errors.noSuchNote);
}
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/messaging/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pack } from '../../../../models/messaging-message';
import read from '../../common/read-messaging-message';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';

export const meta = {
desc: {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const meta = {
export default define(meta, async (ps, user) => {
// Fetch recipient
const recipient = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/messaging/messages/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isValidText } from '../../../../../models/messaging-message';
import DriveFile from '../../../../../models/drive-file';
import define from '../../../define';
import { ApiError } from '../../../error';
import { getUser } from '../../../common/getters';
import { GetterError, getUser } from '../../../common/getters';
import { createMessage } from '../../../../../services/messages/create';
import { isRemoteUser, IUser } from '../../../../../models/user';

Expand Down Expand Up @@ -85,7 +85,7 @@ export default define(meta, async (ps, user) => {

// Fetch recipient
const recipient = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/mute/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ID, { transform } from '../../../../misc/cafy-id';
import Mute from '../../../../models/mute';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';
import { publishMutingChanged } from '../../../../services/server-event';
import { createExpireMuteJob } from '../../../../queue';

Expand Down Expand Up @@ -71,7 +71,7 @@ export default define(meta, async (ps, user) => {

// Get mutee
const mutee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
4 changes: 2 additions & 2 deletions src/server/api/endpoints/user-filter/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import $ from 'cafy';
import ID, { transform } from '../../../../misc/cafy-id';
import define from '../../define';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';
import UserFilter from '../../../../models/user-filter';
import { publishFilterChanged } from '../../../../services/server-event';

Expand Down Expand Up @@ -59,7 +59,7 @@ export default define(meta, async (ps, me) => {

// get target
const target = await getUser(ps.targetId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import define from '../../define';
import { maximum } from '../../../../prelude/array';
import { getHideUserIds } from '../../common/get-hide-users';
import { ApiError } from '../../error';
import { getUser } from '../../common/getters';
import { GetterError, getUser } from '../../common/getters';

export const meta = {
tags: ['users'],
Expand Down Expand Up @@ -50,7 +50,7 @@ export const meta = {
export default define(meta, async (ps, me) => {
// Lookup user
const user = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
if (e instanceof GetterError && e.type === 'noSuchUser') throw new ApiError(meta.errors.noSuchUser);
throw e;
});

Expand Down
Loading

0 comments on commit f8704cf

Please sign in to comment.