movedTo(Uri), alsoKnownAsはユーザーidを返すように
This commit is contained in:
		
							parent
							
								
									eb4bca83fd
								
							
						
					
					
						commit
						3d88a91f61
					
				|  | @ -369,8 +369,11 @@ export class UserEntityService implements OnModuleInit { | |||
| 			...(opts.detail ? { | ||||
| 				url: profile!.url, | ||||
| 				uri: user.uri, | ||||
| 				movedToUri: user.movedToUri ? this.apPersonService.resolvePerson(user.movedToUri).then(user => user.uri).catch(() => null) : null, | ||||
| 				alsoKnownAs: user.alsoKnownAs, | ||||
| 				movedTo: user.movedToUri ? this.apPersonService.resolvePerson(user.movedToUri).then(user => user.id).catch(() => null) : null, | ||||
| 				alsoKnownAs: user.alsoKnownAs | ||||
| 					? Promise.all(user.alsoKnownAs.map(uri => this.apPersonService.fetchPerson(uri).then(user => user?.id).catch(() => null))) | ||||
| 						.then(xs => xs.length === 0 ? null : xs.filter(x => x != null) as string[]) | ||||
| 					: null, | ||||
| 				createdAt: user.createdAt.toISOString(), | ||||
| 				updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null, | ||||
| 				lastFetchedAt: user.lastFetchedAt ? user.lastFetchedAt.toISOString() : null, | ||||
|  |  | |||
|  | @ -80,9 +80,12 @@ export const packedUserDetailedNotMeOnlySchema = { | |||
| 		}, | ||||
| 		alsoKnownAs: { | ||||
| 			type: 'array', | ||||
| 			format: 'uri', | ||||
| 			nullable: true, | ||||
| 			optional: false, | ||||
| 			items: { | ||||
| 				type: 'string', | ||||
| 				format: 'id', | ||||
| 			}, | ||||
| 		}, | ||||
| 		createdAt: { | ||||
| 			type: 'string', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| <template> | ||||
| <div :class="$style.root"> | ||||
| <div v-show="user" :class="$style.root"> | ||||
| 	<i class="ti ti-plane-departure" style="margin-right: 8px;"></i> | ||||
| 	{{ i18n.ts.accountMoved }} | ||||
| 	<MkMention :class="$style.link" :username="username" :host="host ?? localHost"/> | ||||
|  | @ -10,11 +10,17 @@ | |||
| import MkMention from './MkMention.vue'; | ||||
| import { i18n } from '@/i18n'; | ||||
| import { host as localHost } from '@/config'; | ||||
| import { ref } from 'vue'; | ||||
| import { UserLite } from 'misskey-js/built/entities'; | ||||
| import { api } from '@/os'; | ||||
| 
 | ||||
| defineProps<{ | ||||
| 	username: string; | ||||
| 	host: string; | ||||
| const user = ref<UserLite>(); | ||||
| 
 | ||||
| const props = defineProps<{ | ||||
| 	movedTo: string; // user id | ||||
| }>(); | ||||
| 
 | ||||
| api('users/show', { userId: props.movedTo }).then(u => user.value = u); | ||||
| </script> | ||||
| 
 | ||||
| <style lang="scss" module> | ||||
|  |  | |||
|  | @ -51,20 +51,40 @@ import MkFolder from '@/components/MkFolder.vue'; | |||
| import * as os from '@/os'; | ||||
| import { i18n } from '@/i18n'; | ||||
| import { definePageMetadata } from '@/scripts/page-metadata'; | ||||
| import { $i } from '@/account'; | ||||
| import { toString } from 'misskey-js/built/acct'; | ||||
| import { unisonReload } from '@/scripts/unison-reload'; | ||||
| 
 | ||||
| const moveToAccount = ref(''); | ||||
| const accountAliases = ref(['']); | ||||
| 
 | ||||
| async function init() { | ||||
| 	if ($i?.movedTo) { | ||||
| 		const movedTo = await os.api('users/show', { userId: $i.movedTo }); | ||||
| 		moveToAccount.value = movedTo ? toString(movedTo) : ''; | ||||
| 	} else { | ||||
| 		moveToAccount.value = ''; | ||||
| 	} | ||||
| 
 | ||||
| 	if ($i?.alsoKnownAs && $i.alsoKnownAs.length > 0) { | ||||
| 		const alsoKnownAs = await os.api('users/show', { userIds: $i.alsoKnownAs }); | ||||
| 		accountAliases.value = (alsoKnownAs && alsoKnownAs.length > 0) ? alsoKnownAs.map(user => `@${toString(user)}`) : ['']; | ||||
| 	} else { | ||||
| 		accountAliases.value = ['']; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| async function move(): Promise<void> { | ||||
| 	const account = moveToAccount.value; | ||||
| 	const confirm = await os.confirm({ | ||||
| 		type: 'warning', | ||||
| 		text: i18n.t('_accountMigration.migrationConfirm', { account: account.toString() }), | ||||
| 		text: i18n.t('_accountMigration.migrationConfirm', { account }), | ||||
| 	}); | ||||
| 	if (confirm.canceled) return; | ||||
| 	os.apiWithDialog('i/move', { | ||||
| 	await os.apiWithDialog('i/move', { | ||||
| 		moveToAccount: account, | ||||
| 	}); | ||||
| 	unisonReload(); | ||||
| } | ||||
| 
 | ||||
| function add(): void { | ||||
|  | @ -73,12 +93,15 @@ function add(): void { | |||
| 
 | ||||
| async function save(): Promise<void> { | ||||
| 	const alsoKnownAs = accountAliases.value.map(alias => alias.trim()).filter(alias => alias !== ''); | ||||
| 	os.apiWithDialog('i/update', { | ||||
| 	const i = await os.apiWithDialog('i/update', { | ||||
| 		alsoKnownAs, | ||||
| 	}); | ||||
| 	accountAliases.value = alsoKnownAs.length === 0 ? [''] : alsoKnownAs; | ||||
| 	$i.alsoKnownAs = i.alsoKnownAs; | ||||
| 	init(); | ||||
| } | ||||
| 
 | ||||
| init(); | ||||
| 
 | ||||
| definePageMetadata({ | ||||
| 	title: i18n.ts.accountMigration, | ||||
| 	icon: 'ti ti-plane', | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ | |||
| 			<!-- <div class="punished" v-if="user.isSilenced"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSilenced }}</div> --> | ||||
| 
 | ||||
| 			<div class="profile _gaps"> | ||||
| 				<MkAccountMoved v-if="user.movedToUri" :host="user.movedToUri.host" :username="user.movedToUri.username"/> | ||||
| 				<MkAccountMoved v-if="user.movedTo" :movedTo="user.movedTo" /> | ||||
| 				<MkRemoteCaution v-if="user.host != null" :href="user.url ?? user.uri!" class="warn"/> | ||||
| 
 | ||||
| 				<div :key="user.id" class="main _panel"> | ||||
|  |  | |||
|  | @ -2631,6 +2631,7 @@ type User = UserLite | UserDetailed; | |||
| 
 | ||||
| // @public (undocumented) | ||||
| type UserDetailed = UserLite & { | ||||
|     alsoKnownAs: string[]; | ||||
|     bannerBlurhash: string | null; | ||||
|     bannerColor: string | null; | ||||
|     bannerUrl: string | null; | ||||
|  | @ -2661,7 +2662,7 @@ type UserDetailed = UserLite & { | |||
|     lang: string | null; | ||||
|     lastFetchedAt?: DateString; | ||||
|     location: string | null; | ||||
|     movedToUri: string; | ||||
|     movedTo: string; | ||||
|     notesCount: number; | ||||
|     pinnedNoteIds: ID[]; | ||||
|     pinnedNotes: Note[]; | ||||
|  | @ -2695,7 +2696,6 @@ type UserLite = { | |||
|     onlineStatus: 'online' | 'active' | 'offline' | 'unknown'; | ||||
|     avatarUrl: string; | ||||
|     avatarBlurhash: string; | ||||
|     alsoKnownAs: string[]; | ||||
|     emojis: { | ||||
|         name: string; | ||||
|         url: string; | ||||
|  |  | |||
|  | @ -14,7 +14,6 @@ export type UserLite = { | |||
| 	onlineStatus: 'online' | 'active' | 'offline' | 'unknown'; | ||||
| 	avatarUrl: string; | ||||
| 	avatarBlurhash: string; | ||||
| 	alsoKnownAs: string[]; | ||||
| 	emojis: { | ||||
| 		name: string; | ||||
| 		url: string; | ||||
|  | @ -30,6 +29,7 @@ export type UserLite = { | |||
| }; | ||||
| 
 | ||||
| export type UserDetailed = UserLite & { | ||||
| 	alsoKnownAs: string[]; | ||||
| 	bannerBlurhash: string | null; | ||||
| 	bannerColor: string | null; | ||||
| 	bannerUrl: string | null; | ||||
|  | @ -57,7 +57,7 @@ export type UserDetailed = UserLite & { | |||
| 	lang: string | null; | ||||
| 	lastFetchedAt?: DateString; | ||||
| 	location: string | null; | ||||
| 	movedToUri: string; | ||||
| 	movedTo: string; | ||||
| 	notesCount: number; | ||||
| 	pinnedNoteIds: ID[]; | ||||
| 	pinnedNotes: Note[]; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue