mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-29 05:17:39 -07:00
Fix move endpoint
This commit is contained in:
parent
c8c652dc6c
commit
367e19727e
3 changed files with 22 additions and 21 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "calckey",
|
||||
"version": "13.0.0-rc4",
|
||||
"version": "13.0.0-rc5",
|
||||
"codename": "aqua",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { User } from '@/models/entities/user.js';
|
|||
import { resolveUser } from '@/remote/resolve-user.js';
|
||||
import { DAY } from '@/const.js';
|
||||
import DeliverManager from '@/remote/activitypub/deliver-manager.js';
|
||||
import { deliver } from '@/queue/index.js';
|
||||
import { renderActivity } from '@/remote/activitypub/renderer/index.js';
|
||||
import type { IActivity } from '@/remote/activitypub/type.js';
|
||||
import define from '../../define.js';
|
||||
|
@ -51,6 +52,19 @@ export const paramDef = {
|
|||
required: ['moveToAccount'],
|
||||
} as const;
|
||||
|
||||
function moveActivity(to: User, from: User) {
|
||||
const activity = {
|
||||
id: 'foo',
|
||||
actor: from,
|
||||
type: 'Move',
|
||||
object: from,
|
||||
target: to,
|
||||
} as any;
|
||||
|
||||
const content = renderActivity(activity);
|
||||
deliver(to, content, from.inbox);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
if (!ps.moveToAccount) throw new ApiError(meta.errors.noSuchMoveTarget);
|
||||
|
@ -75,23 +89,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
if (!allowed || !moveTo.uri || !user.uri) throw new ApiError(meta.errors.remoteAccountForbids);
|
||||
|
||||
(async (): Promise<void> => {
|
||||
const moveAct = await moveActivity(moveTo.uri!, user.uri!);
|
||||
const moveAct = moveActivity(moveTo, user);
|
||||
const dm = new DeliverManager(user, moveAct);
|
||||
dm.addFollowersRecipe();
|
||||
dm.execute();
|
||||
})();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
async function moveActivity(to: string, from: string): Promise<IActivity | null> {
|
||||
const activity = {
|
||||
id: 'foo',
|
||||
actor: from,
|
||||
type: 'Move',
|
||||
object: from,
|
||||
target: to,
|
||||
} as any;
|
||||
|
||||
return renderActivity(activity);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ async function move(account): Promise<void> {
|
|||
text: i18n.t('migrationConfirm', { account: account.toString() }),
|
||||
});
|
||||
if (confirm.canceled) return;
|
||||
os.api('i/move', {
|
||||
os.apiWithDialog('i/move', {
|
||||
moveToAccount: account,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue