Resolve #1669
This commit is contained in:
		
							parent
							
								
									d355f3f77c
								
							
						
					
					
						commit
						7ed3448e13
					
				
					 19 changed files with 152 additions and 216 deletions
				
			
		|  | @ -15,6 +15,7 @@ Misskey v12では、クライアントが設計し直され、全く新しいUI | ||||||
| ### ⚠Breaking Changes | ### ⚠Breaking Changes | ||||||
| * お知らせがリセットされます。 | * お知らせがリセットされます。 | ||||||
| * 通知がリセットされます。 | * 通知がリセットされます。 | ||||||
|  | * アカウントの外部サービス連携情報がリセットされます。 | ||||||
| * インスタンスの閉鎖情報がリセットされます。 | * インスタンスの閉鎖情報がリセットされます。 | ||||||
| * モデレーターがインスタンス設定を閲覧したり変更したりできなくなります(それらができるのはAdminのみになります)。 | * モデレーターがインスタンス設定を閲覧したり変更したりできなくなります(それらができるのはAdminのみになります)。 | ||||||
| 	* モデレーターが出来るのは、ユーザーのサイレンス/凍結などに限られます。 | 	* モデレーターが出来るのは、ユーザーのサイレンス/凍結などに限られます。 | ||||||
|  | @ -56,6 +57,8 @@ Misskey v12では、クライアントが設計し直され、全く新しいUI | ||||||
| * Elasticsearchをインストールしなくても全文検索できるように | * Elasticsearchをインストールしなくても全文検索できるように | ||||||
| * リモートのカスタム絵文字をコピーしてくる機能を追加 | * リモートのカスタム絵文字をコピーしてくる機能を追加 | ||||||
| * 自分の送ったフォローリクエストが承認されたときの通知を追加 | * 自分の送ったフォローリクエストが承認されたときの通知を追加 | ||||||
|  | * 外部サービス連携情報をプロフィールに表示しないように | ||||||
|  | 	* 今後個別に表示するかどうか設定できるようになる予定 | ||||||
| * ハイライト投稿の並びを人気順ではなく投稿日時順に | * ハイライト投稿の並びを人気順ではなく投稿日時順に | ||||||
| * AIDのノイズがあまりよくないのを改善 | * AIDのノイズがあまりよくないのを改善 | ||||||
| * WebAuthNで internal というタイプもあるようなのでそれも使えるように | * WebAuthNで internal というタイプもあるようなのでそれも使えるように | ||||||
|  |  | ||||||
							
								
								
									
										46
									
								
								migration/1580508795118-v12-12.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								migration/1580508795118-v12-12.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,46 @@ | ||||||
|  | import {MigrationInterface, QueryRunner} from "typeorm"; | ||||||
|  | 
 | ||||||
|  | export class v12121580508795118 implements MigrationInterface { | ||||||
|  |     name = 'v12121580508795118' | ||||||
|  | 
 | ||||||
|  |     public async up(queryRunner: QueryRunner): Promise<any> { | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "twitter"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "twitterAccessToken"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "twitterAccessTokenSecret"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "twitterUserId"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "twitterScreenName"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "github"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "githubAccessToken"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "githubId"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "githubLogin"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discord"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordAccessToken"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordRefreshToken"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordExpiresDate"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordId"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordUsername"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "discordDiscriminator"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "integrations" jsonb NOT NULL DEFAULT '{}'`, undefined); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public async down(queryRunner: QueryRunner): Promise<any> { | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "integrations"`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordDiscriminator" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordUsername" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordId" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordExpiresDate" character varying(64)`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordRefreshToken" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discordAccessToken" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "discord" boolean NOT NULL DEFAULT false`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "githubLogin" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "githubId" character varying(64)`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "githubAccessToken" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "github" boolean NOT NULL DEFAULT false`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "twitterScreenName" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "twitterUserId" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "twitterAccessTokenSecret" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "twitterAccessToken" character varying(64) DEFAULT NULL`, undefined); | ||||||
|  |         await queryRunner.query(`ALTER TABLE "user_profile" ADD "twitter" boolean NOT NULL DEFAULT false`, undefined); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| { | { | ||||||
| 	"name": "misskey", | 	"name": "misskey", | ||||||
| 	"author": "syuilo <syuilotan@yahoo.co.jp>", | 	"author": "syuilo <syuilotan@yahoo.co.jp>", | ||||||
| 	"version": "12.0.0-alpha.12", | 	"version": "12.0.0-alpha.13", | ||||||
| 	"codename": "indigo", | 	"codename": "indigo", | ||||||
| 	"repository": { | 	"repository": { | ||||||
| 		"type": "git", | 		"type": "git", | ||||||
|  |  | ||||||
|  | @ -1,24 +1,25 @@ | ||||||
| <template> | <template> | ||||||
| <section class="_card" v-if="enableTwitterIntegration || enableDiscordIntegration || enableGithubIntegration"> | <section class="_card" v-if="enableTwitterIntegration || enableDiscordIntegration || enableGithubIntegration"> | ||||||
| 	<div class="_title"><fa :icon="faShareAlt"/> {{ $t('integration') }}</div> | 	<div class="_title"><fa :icon="faShareAlt"/> {{ $t('integration') }}</div> | ||||||
|  | 
 | ||||||
| 	<div class="_content" v-if="enableTwitterIntegration"> | 	<div class="_content" v-if="enableTwitterIntegration"> | ||||||
| 		<header><fa :icon="faTwitter"/> Twitter</header> | 		<header><fa :icon="faTwitter"/> Twitter</header> | ||||||
| 		<p v-if="$store.state.i.twitter">{{ $t('connectedTo') }}: <a :href="`https://twitter.com/${$store.state.i.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ $store.state.i.twitter.screenName }}</a></p> | 		<p v-if="integrations.twitter">{{ $t('connectedTo') }}: <a :href="`https://twitter.com/${integrations.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ integrations.twitter.screenName }}</a></p> | ||||||
| 		<mk-button v-if="$store.state.i.twitter" @click="disconnectTwitter">{{ $t('disconnectSerice') }}</mk-button> | 		<mk-button v-if="integrations.twitter" @click="disconnectTwitter">{{ $t('disconnectSerice') }}</mk-button> | ||||||
| 		<mk-button v-else @click="connectTwitter">{{ $t('connectSerice') }}</mk-button> | 		<mk-button v-else @click="connectTwitter">{{ $t('connectSerice') }}</mk-button> | ||||||
| 	</div> | 	</div> | ||||||
| 
 | 
 | ||||||
| 	<div class="_content" v-if="enableDiscordIntegration"> | 	<div class="_content" v-if="enableDiscordIntegration"> | ||||||
| 		<header><fa :icon="faDiscord"/> Discord</header> | 		<header><fa :icon="faDiscord"/> Discord</header> | ||||||
| 		<p v-if="$store.state.i.discord">{{ $t('connectedTo') }}: <a :href="`https://discordapp.com/users/${$store.state.i.discord.id}`" rel="nofollow noopener" target="_blank">@{{ $store.state.i.discord.username }}#{{ $store.state.i.discord.discriminator }}</a></p> | 		<p v-if="integrations.discord">{{ $t('connectedTo') }}: <a :href="`https://discordapp.com/users/${integrations.discord.id}`" rel="nofollow noopener" target="_blank">@{{ integrations.discord.username }}#{{ integrations.discord.discriminator }}</a></p> | ||||||
| 		<mk-button v-if="$store.state.i.discord" @click="disconnectDiscord">{{ $t('disconnectSerice') }}</mk-button> | 		<mk-button v-if="integrations.discord" @click="disconnectDiscord">{{ $t('disconnectSerice') }}</mk-button> | ||||||
| 		<mk-button v-else @click="connectDiscord">{{ $t('connectSerice') }}</mk-button> | 		<mk-button v-else @click="connectDiscord">{{ $t('connectSerice') }}</mk-button> | ||||||
| 	</div> | 	</div> | ||||||
| 
 | 
 | ||||||
| 	<div class="_content" v-if="enableGithubIntegration"> | 	<div class="_content" v-if="enableGithubIntegration"> | ||||||
| 		<header><fa :icon="faGithub"/> GitHub</header> | 		<header><fa :icon="faGithub"/> GitHub</header> | ||||||
| 		<p v-if="$store.state.i.github">{{ $t('connectedTo') }}: <a :href="`https://github.com/${$store.state.i.github.login}`" rel="nofollow noopener" target="_blank">@{{ $store.state.i.github.login }}</a></p> | 		<p v-if="integrations.github">{{ $t('connectedTo') }}: <a :href="`https://github.com/${integrations.github.login}`" rel="nofollow noopener" target="_blank">@{{ integrations.github.login }}</a></p> | ||||||
| 		<mk-button v-if="$store.state.i.github" @click="disconnectGithub">{{ $t('disconnectSerice') }}</mk-button> | 		<mk-button v-if="integrations.github" @click="disconnectGithub">{{ $t('disconnectSerice') }}</mk-button> | ||||||
| 		<mk-button v-else @click="connectGithub">{{ $t('connectSerice') }}</mk-button> | 		<mk-button v-else @click="connectGithub">{{ $t('connectSerice') }}</mk-button> | ||||||
| 	</div> | 	</div> | ||||||
| </section> | </section> | ||||||
|  | @ -52,6 +53,12 @@ export default Vue.extend({ | ||||||
| 		}; | 		}; | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
|  | 	computed: { | ||||||
|  | 		integrations() { | ||||||
|  | 			return this.$store.state.i.integrations; | ||||||
|  | 		} | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
| 	created() { | 	created() { | ||||||
| 		this.$root.getMeta().then(meta => { | 		this.$root.getMeta().then(meta => { | ||||||
| 			this.enableTwitterIntegration = meta.enableTwitterIntegration; | 			this.enableTwitterIntegration = meta.enableTwitterIntegration; | ||||||
|  | @ -66,14 +73,14 @@ export default Vue.extend({ | ||||||
| 			` domain=${document.location.hostname}; max-age=31536000;` + | 			` domain=${document.location.hostname}; max-age=31536000;` + | ||||||
| 			(document.location.protocol.startsWith('https') ? ' secure' : ''); | 			(document.location.protocol.startsWith('https') ? ' secure' : ''); | ||||||
| 		} | 		} | ||||||
| 		this.$watch('$store.state.i', () => { | 		this.$watch('integrations', () => { | ||||||
| 			if (this.$store.state.i.twitter) { | 			if (this.integrations.twitter) { | ||||||
| 				if (this.twitterForm) this.twitterForm.close(); | 				if (this.twitterForm) this.twitterForm.close(); | ||||||
| 			} | 			} | ||||||
| 			if (this.$store.state.i.discord) { | 			if (this.integrations.discord) { | ||||||
| 				if (this.discordForm) this.discordForm.close(); | 				if (this.discordForm) this.discordForm.close(); | ||||||
| 			} | 			} | ||||||
| 			if (this.$store.state.i.github) { | 			if (this.integrations.github) { | ||||||
| 				if (this.githubForm) this.githubForm.close(); | 				if (this.githubForm) this.githubForm.close(); | ||||||
| 			} | 			} | ||||||
| 		}, { | 		}, { | ||||||
|  |  | ||||||
|  | @ -137,87 +137,10 @@ export class UserProfile { | ||||||
| 	@JoinColumn() | 	@JoinColumn() | ||||||
| 	public pinnedPage: Page | null; | 	public pinnedPage: Page | null; | ||||||
| 
 | 
 | ||||||
| 	//#region Linking
 | 	@Column('jsonb', { | ||||||
| 	@Column('boolean', { | 		default: {} | ||||||
| 		default: false, |  | ||||||
| 	}) | 	}) | ||||||
| 	public twitter: boolean; | 	public integrations: Record<string, any>; | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public twitterAccessToken: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public twitterAccessTokenSecret: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public twitterUserId: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public twitterScreenName: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('boolean', { |  | ||||||
| 		default: false, |  | ||||||
| 	}) |  | ||||||
| 	public github: boolean; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public githubAccessToken: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public githubId: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public githubLogin: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('boolean', { |  | ||||||
| 		default: false, |  | ||||||
| 	}) |  | ||||||
| 	public discord: boolean; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordAccessToken: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordRefreshToken: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordExpiresDate: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordId: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordUsername: string | null; |  | ||||||
| 
 |  | ||||||
| 	@Column('varchar', { |  | ||||||
| 		length: 64, nullable: true, default: null, |  | ||||||
| 	}) |  | ||||||
| 	public discordDiscriminator: string | null; |  | ||||||
| 	//#endregion
 |  | ||||||
| 
 | 
 | ||||||
| 	//#region Denormalized fields
 | 	//#region Denormalized fields
 | ||||||
| 	@Index() | 	@Index() | ||||||
|  |  | ||||||
|  | @ -213,19 +213,6 @@ export class UserRepository extends Repository<User> { | ||||||
| 						userId: user.id | 						userId: user.id | ||||||
| 					}).then(result => result >= 1) | 					}).then(result => result >= 1) | ||||||
| 					: false, | 					: false, | ||||||
| 				twitter: profile!.twitter ? { |  | ||||||
| 					id: profile!.twitterUserId, |  | ||||||
| 					screenName: profile!.twitterScreenName |  | ||||||
| 				} : null, |  | ||||||
| 				github: profile!.github ? { |  | ||||||
| 					id: profile!.githubId, |  | ||||||
| 					login: profile!.githubLogin |  | ||||||
| 				} : null, |  | ||||||
| 				discord: profile!.discord ? { |  | ||||||
| 					id: profile!.discordId, |  | ||||||
| 					username: profile!.discordUsername, |  | ||||||
| 					discriminator: profile!.discordDiscriminator |  | ||||||
| 				} : null, |  | ||||||
| 			} : {}), | 			} : {}), | ||||||
| 
 | 
 | ||||||
| 			...(opts.detail && meId === user.id ? { | 			...(opts.detail && meId === user.id ? { | ||||||
|  | @ -242,6 +229,7 @@ export class UserRepository extends Repository<User> { | ||||||
| 				pendingReceivedFollowRequestsCount: FollowRequests.count({ | 				pendingReceivedFollowRequestsCount: FollowRequests.count({ | ||||||
| 					followeeId: user.id | 					followeeId: user.id | ||||||
| 				}), | 				}), | ||||||
|  | 				integrations: profile?.integrations, | ||||||
| 			} : {}), | 			} : {}), | ||||||
| 
 | 
 | ||||||
| 			...(opts.includeSecrets ? { | 			...(opts.includeSecrets ? { | ||||||
|  |  | ||||||
|  | @ -306,7 +306,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint | ||||||
| 
 | 
 | ||||||
| 	const emojiNames = emojis.map(emoji => emoji.name); | 	const emojiNames = emojis.map(emoji => emoji.name); | ||||||
| 
 | 
 | ||||||
| 	const { fields, services } = analyzeAttachments(person.attachment || []); | 	const { fields } = analyzeAttachments(person.attachment || []); | ||||||
| 
 | 
 | ||||||
| 	const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 32); | 	const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 32); | ||||||
| 
 | 
 | ||||||
|  | @ -347,13 +347,6 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint | ||||||
| 		url: person.url, | 		url: person.url, | ||||||
| 		fields, | 		fields, | ||||||
| 		description: person.summary ? fromHtml(person.summary) : null, | 		description: person.summary ? fromHtml(person.summary) : null, | ||||||
| 		twitterUserId: services.twitter ? services.twitter.userId : null, |  | ||||||
| 		twitterScreenName: services.twitter ? services.twitter.screenName : null, |  | ||||||
| 		githubId: services.github ? services.github.id : null, |  | ||||||
| 		githubLogin: services.github ? services.github.login : null, |  | ||||||
| 		discordId: services.discord ? services.discord.id : null, |  | ||||||
| 		discordUsername: services.discord ? services.discord.username : null, |  | ||||||
| 		discordDiscriminator: services.discord ? services.discord.discriminator : null, |  | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	// ハッシュタグ更新
 | 	// ハッシュタグ更新
 | ||||||
|  |  | ||||||
|  | @ -39,45 +39,6 @@ export async function renderPerson(user: ILocalUser) { | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (profile.twitter) { |  | ||||||
| 		attachment.push({ |  | ||||||
| 			type: 'PropertyValue', |  | ||||||
| 			name: 'Twitter', |  | ||||||
| 			value: `<a href="https://twitter.com/intent/user?user_id=${profile.twitterUserId}" rel="me nofollow noopener" target="_blank"><span>@${profile.twitterScreenName}</span></a>`, |  | ||||||
| 			identifier: { |  | ||||||
| 				type: 'PropertyValue', |  | ||||||
| 				name: 'misskey:authentication:twitter', |  | ||||||
| 				value: `${profile.twitterUserId}@${profile.twitterScreenName}` |  | ||||||
| 			} |  | ||||||
| 		}); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (profile.github) { |  | ||||||
| 		attachment.push({ |  | ||||||
| 			type: 'PropertyValue', |  | ||||||
| 			name: 'GitHub', |  | ||||||
| 			value: `<a href="https://github.com/${profile.githubLogin}" rel="me nofollow noopener" target="_blank"><span>@${profile.githubLogin}</span></a>`, |  | ||||||
| 			identifier: { |  | ||||||
| 				type: 'PropertyValue', |  | ||||||
| 				name: 'misskey:authentication:github', |  | ||||||
| 				value: `${profile.githubId}@${profile.githubLogin}` |  | ||||||
| 			} |  | ||||||
| 		}); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (profile.discord) { |  | ||||||
| 		attachment.push({ |  | ||||||
| 			type: 'PropertyValue', |  | ||||||
| 			name: 'Discord', |  | ||||||
| 			value: `<a href="https://discordapp.com/users/${profile.discordId}" rel="me nofollow noopener" target="_blank"><span>${profile.discordUsername}#${profile.discordDiscriminator}</span></a>`, |  | ||||||
| 			identifier: { |  | ||||||
| 				type: 'PropertyValue', |  | ||||||
| 				name: 'misskey:authentication:discord', |  | ||||||
| 				value: `${profile.discordId}@${profile.discordUsername}#${profile.discordDiscriminator}` |  | ||||||
| 			} |  | ||||||
| 		}); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	const emojis = await getEmojis(user.emojis); | 	const emojis = await getEmojis(user.emojis); | ||||||
| 	const apemojis = emojis.map(emoji => renderEmoji(emoji)); | 	const apemojis = emojis.map(emoji => renderEmoji(emoji)); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 		throw new Error('not verified'); | 		throw new Error('not verified'); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		twoFactorSecret: profile.twoFactorTempSecret, | 		twoFactorSecret: profile.twoFactorTempSecret, | ||||||
| 		twoFactorEnabled: true | 		twoFactorEnabled: true | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 		length: 32 | 		length: 32 | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		twoFactorTempSecret: secret.base32 | 		twoFactorTempSecret: secret.base32 | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 		throw new Error('incorrect password'); | 		throw new Error('incorrect password'); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		twoFactorSecret: null, | 		twoFactorSecret: null, | ||||||
| 		twoFactorEnabled: false | 		twoFactorEnabled: false | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 	const salt = await bcrypt.genSalt(8); | 	const salt = await bcrypt.genSalt(8); | ||||||
| 	const hash = await bcrypt.hash(ps.newPassword, salt); | 	const hash = await bcrypt.hash(ps.newPassword, salt); | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		password: hash | 		password: hash | ||||||
| 	}); | 	}); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -49,7 +49,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 		throw new ApiError(meta.errors.incorrectPassword); | 		throw new ApiError(meta.errors.incorrectPassword); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		email: ps.email, | 		email: ps.email, | ||||||
| 		emailVerified: false, | 		emailVerified: false, | ||||||
| 		emailVerifyCode: null | 		emailVerifyCode: null | ||||||
|  | @ -66,7 +66,7 @@ export default define(meta, async (ps, user) => { | ||||||
| 	if (ps.email != null) { | 	if (ps.email != null) { | ||||||
| 		const code = rndstr('a-z0-9', 16); | 		const code = rndstr('a-z0-9', 16); | ||||||
| 
 | 
 | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		await UserProfiles.update(user.id, { | ||||||
| 			emailVerifyCode: code | 			emailVerifyCode: code | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -268,7 +268,7 @@ export default define(meta, async (ps, user, app) => { | ||||||
| 	//#endregion
 | 	//#endregion
 | ||||||
| 
 | 
 | ||||||
| 	if (Object.keys(updates).length > 0) await Users.update(user.id, updates); | 	if (Object.keys(updates).length > 0) await Users.update(user.id, updates); | ||||||
| 	if (Object.keys(profileUpdates).length > 0) await UserProfiles.update({ userId: user.id }, profileUpdates); | 	if (Object.keys(profileUpdates).length > 0) await UserProfiles.update(user.id, profileUpdates); | ||||||
| 
 | 
 | ||||||
| 	const iObj = await Users.pack(user.id, user, { | 	const iObj = await Users.pack(user.id, user, { | ||||||
| 		detail: true, | 		detail: true, | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ export default define(meta, async (ps, me) => { | ||||||
| 	const profile = await UserProfiles.findOne(user.id).then(ensure); | 	const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 
 | 
 | ||||||
| 	if (profile.room.furnitures == null) { | 	if (profile.room.furnitures == null) { | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		await UserProfiles.update(user.id, { | ||||||
| 			room: { | 			room: { | ||||||
| 				furnitures: [], | 				furnitures: [], | ||||||
| 				...profile.room | 				...profile.room | ||||||
|  | @ -66,7 +66,7 @@ export default define(meta, async (ps, me) => { | ||||||
| 
 | 
 | ||||||
| 	if (profile.room.roomType == null) { | 	if (profile.room.roomType == null) { | ||||||
| 		const initialType = 'default'; | 		const initialType = 'default'; | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		await UserProfiles.update(user.id, { | ||||||
| 			room: { | 			room: { | ||||||
| 				roomType: initialType as any, | 				roomType: initialType as any, | ||||||
| 				...profile.room | 				...profile.room | ||||||
|  | @ -78,7 +78,7 @@ export default define(meta, async (ps, me) => { | ||||||
| 
 | 
 | ||||||
| 	if (profile.room.carpetColor == null) { | 	if (profile.room.carpetColor == null) { | ||||||
| 		const initialColor = '#85CAF0'; | 		const initialColor = '#85CAF0'; | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		await UserProfiles.update(user.id, { | ||||||
| 			room: { | 			room: { | ||||||
| 				carpetColor: initialColor as any, | 				carpetColor: initialColor as any, | ||||||
| 				...profile.room | 				...profile.room | ||||||
|  |  | ||||||
|  | @ -32,7 +32,7 @@ export const meta = { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default define(meta, async (ps, user) => { | export default define(meta, async (ps, user) => { | ||||||
| 	await UserProfiles.update({ userId: user.id }, { | 	await UserProfiles.update(user.id, { | ||||||
| 		room: ps.room as any | 		room: ps.room as any | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -46,16 +46,12 @@ router.get('/disconnect/discord', async ctx => { | ||||||
| 		token: userToken | 		token: userToken | ||||||
| 	}).then(ensure); | 	}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ | 	const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 		userId: user.id | 
 | ||||||
| 	}, { | 	delete profile.integrations.discord; | ||||||
| 		discord: false, | 
 | ||||||
| 		discordAccessToken: null, | 	await UserProfiles.update(user.id, { | ||||||
| 		discordRefreshToken: null, | 		integrations: profile.integrations, | ||||||
| 		discordExpiresDate: null, |  | ||||||
| 		discordId: null, |  | ||||||
| 		discordUsername: null, |  | ||||||
| 		discordDiscriminator: null, |  | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	ctx.body = `Discordの連携を解除しました :v:`; | 	ctx.body = `Discordの連携を解除しました :v:`; | ||||||
|  | @ -203,7 +199,7 @@ router.get('/dc/cb', async ctx => { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const profile = await UserProfiles.createQueryBuilder() | 		const profile = await UserProfiles.createQueryBuilder() | ||||||
| 			.where('"discordId" = :id', { id: id }) | 			.where('"integrations"->"discord"->"id" = :id', { id: id }) | ||||||
| 			.andWhere('"userHost" IS NULL') | 			.andWhere('"userHost" IS NULL') | ||||||
| 			.getOne(); | 			.getOne(); | ||||||
| 
 | 
 | ||||||
|  | @ -212,13 +208,17 @@ router.get('/dc/cb', async ctx => { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		await UserProfiles.update({ userId: profile.userId }, { | 		await UserProfiles.update(profile.userId, { | ||||||
| 			discord: true, | 			integrations: { | ||||||
| 			discordAccessToken: accessToken, | 				...profile.integrations, | ||||||
| 			discordRefreshToken: refreshToken, | 				discord: { | ||||||
| 			discordExpiresDate: expiresDate, | 					accessToken: accessToken, | ||||||
| 			discordUsername: username, | 					refreshToken: refreshToken, | ||||||
| 			discordDiscriminator: discriminator | 					expiresDate: expiresDate, | ||||||
|  | 					username: username, | ||||||
|  | 					discriminator: discriminator | ||||||
|  | 				} | ||||||
|  | 			}, | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		signin(ctx, await Users.findOne(profile.userId) as ILocalUser, true); | 		signin(ctx, await Users.findOne(profile.userId) as ILocalUser, true); | ||||||
|  | @ -284,14 +284,20 @@ router.get('/dc/cb', async ctx => { | ||||||
| 			token: userToken | 			token: userToken | ||||||
| 		}).then(ensure); | 		}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 			discord: true, | 
 | ||||||
| 			discordAccessToken: accessToken, | 		await UserProfiles.update(user.id, { | ||||||
| 			discordRefreshToken: refreshToken, | 			integrations: { | ||||||
| 			discordExpiresDate: expiresDate, | 				...profile.integrations, | ||||||
| 			discordId: id, | 				discord: { | ||||||
| 			discordUsername: username, | 					accessToken: accessToken, | ||||||
| 			discordDiscriminator: discriminator | 					refreshToken: refreshToken, | ||||||
|  | 					expiresDate: expiresDate, | ||||||
|  | 					id: id, | ||||||
|  | 					username: username, | ||||||
|  | 					discriminator: discriminator | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		ctx.body = `Discord: @${username}#${discriminator} を、Misskey: @${user.username} に接続しました!`; | 		ctx.body = `Discord: @${username}#${discriminator} を、Misskey: @${user.username} に接続しました!`; | ||||||
|  |  | ||||||
|  | @ -46,13 +46,12 @@ router.get('/disconnect/github', async ctx => { | ||||||
| 		token: userToken | 		token: userToken | ||||||
| 	}).then(ensure); | 	}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ | 	const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 		userId: user.id | 
 | ||||||
| 	}, { | 	delete profile.integrations.github; | ||||||
| 		github: false, | 
 | ||||||
| 		githubAccessToken: null, | 	await UserProfiles.update(user.id, { | ||||||
| 		githubId: null, | 		integrations: profile.integrations, | ||||||
| 		githubLogin: null, |  | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	ctx.body = `GitHubの連携を解除しました :v:`; | 	ctx.body = `GitHubの連携を解除しました :v:`; | ||||||
|  | @ -193,7 +192,7 @@ router.get('/gh/cb', async ctx => { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const link = await UserProfiles.createQueryBuilder() | 		const link = await UserProfiles.createQueryBuilder() | ||||||
| 			.where('"githubId" = :id', { id: id }) | 			.where('"integrations"->"github"->"id" = :id', { id: id }) | ||||||
| 			.andWhere('"userHost" IS NULL') | 			.andWhere('"userHost" IS NULL') | ||||||
| 			.getOne(); | 			.getOne(); | ||||||
| 
 | 
 | ||||||
|  | @ -260,11 +259,17 @@ router.get('/gh/cb', async ctx => { | ||||||
| 			token: userToken | 			token: userToken | ||||||
| 		}).then(ensure); | 		}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 			github: true, | 
 | ||||||
| 			githubAccessToken: accessToken, | 		await UserProfiles.update(user.id, { | ||||||
| 			githubId: id, | 			integrations: { | ||||||
| 			githubLogin: login, | 				...profile.integrations, | ||||||
|  | 				github: { | ||||||
|  | 					accessToken: accessToken, | ||||||
|  | 					id: id, | ||||||
|  | 					login: login, | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		ctx.body = `GitHub: @${login} を、Misskey: @${user.username} に接続しました!`; | 		ctx.body = `GitHub: @${login} を、Misskey: @${user.username} に接続しました!`; | ||||||
|  |  | ||||||
|  | @ -45,14 +45,12 @@ router.get('/disconnect/twitter', async ctx => { | ||||||
| 		token: userToken | 		token: userToken | ||||||
| 	}).then(ensure); | 	}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 	await UserProfiles.update({ | 	const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 		userId: user.id | 
 | ||||||
| 	}, { | 	delete profile.integrations.twitter; | ||||||
| 		twitter: false, | 
 | ||||||
| 		twitterAccessToken: null, | 	await UserProfiles.update(user.id, { | ||||||
| 		twitterAccessTokenSecret: null, | 		integrations: profile.integrations, | ||||||
| 		twitterUserId: null, |  | ||||||
| 		twitterScreenName: null, |  | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	ctx.body = `Twitterの連携を解除しました :v:`; | 	ctx.body = `Twitterの連携を解除しました :v:`; | ||||||
|  | @ -141,7 +139,7 @@ router.get('/tw/cb', async ctx => { | ||||||
| 		const result = await twAuth!.done(JSON.parse(twCtx), ctx.query.oauth_verifier); | 		const result = await twAuth!.done(JSON.parse(twCtx), ctx.query.oauth_verifier); | ||||||
| 
 | 
 | ||||||
| 		const link = await UserProfiles.createQueryBuilder() | 		const link = await UserProfiles.createQueryBuilder() | ||||||
| 			.where('"twitterUserId" = :id', { id: result.userId }) | 			.where('"integrations"->"twitter"->"userId" = :id', { id: result.userId }) | ||||||
| 			.andWhere('"userHost" IS NULL') | 			.andWhere('"userHost" IS NULL') | ||||||
| 			.getOne(); | 			.getOne(); | ||||||
| 
 | 
 | ||||||
|  | @ -174,12 +172,18 @@ router.get('/tw/cb', async ctx => { | ||||||
| 			token: userToken | 			token: userToken | ||||||
| 		}).then(ensure); | 		}).then(ensure); | ||||||
| 
 | 
 | ||||||
| 		await UserProfiles.update({ userId: user.id }, { | 		const profile = await UserProfiles.findOne(user.id).then(ensure); | ||||||
| 			twitter: true, | 
 | ||||||
| 			twitterAccessToken: result.accessToken, | 		await UserProfiles.update(user.id, { | ||||||
| 			twitterAccessTokenSecret: result.accessTokenSecret, | 			integrations: { | ||||||
| 			twitterUserId: result.userId, | 				...profile.integrations, | ||||||
| 			twitterScreenName: result.screenName, | 				twitter: { | ||||||
|  | 					accessToken: result.accessToken, | ||||||
|  | 					accessTokenSecret: result.accessTokenSecret, | ||||||
|  | 					userId: result.userId, | ||||||
|  | 					screenName: result.screenName, | ||||||
|  | 				} | ||||||
|  | 			}, | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`; | 		ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue