forked from FoundKeyGang/FoundKey
プロキシアカウントをユーザー名ではなくIDで保存するように
This commit is contained in:
parent
ce589fee8c
commit
8818648740
8 changed files with 67 additions and 22 deletions
|
@ -19,6 +19,7 @@ v12ではいくつかインスタンスにとって破壊的な変更があり
|
||||||
* 通知がリセットされます。
|
* 通知がリセットされます。
|
||||||
* アカウントの外部サービス連携情報がリセットされます。
|
* アカウントの外部サービス連携情報がリセットされます。
|
||||||
* インスタンスの閉鎖情報がリセットされます。
|
* インスタンスの閉鎖情報がリセットされます。
|
||||||
|
* プロキシアカウント設定情報がリセットされます。
|
||||||
* モデレーターがインスタンス設定を閲覧したり変更したりできなくなります(それらができるのはAdminのみになります)。
|
* モデレーターがインスタンス設定を閲覧したり変更したりできなくなります(それらができるのはAdminのみになります)。
|
||||||
* モデレーターが出来るのは、ユーザーのサイレンス/凍結などに限られます。
|
* モデレーターが出来るのは、ユーザーのサイレンス/凍結などに限られます。
|
||||||
* 従来と同じ権限を与えたい場合、モデレーターをAdminに設定することを検討してください(Adminは複数人設定可能です)。
|
* 従来と同じ権限を与えたい場合、モデレーターをAdminに設定することを検討してください(Adminは複数人設定可能です)。
|
||||||
|
|
20
migration/1580864313253-v12-14.ts
Normal file
20
migration/1580864313253-v12-14.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||||
|
|
||||||
|
export class v12141580864313253 implements MigrationInterface {
|
||||||
|
name = 'v12141580864313253'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" RENAME COLUMN "proxyAccount" TO "proxyAccountId"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "proxyAccountId"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "proxyAccountId" character varying(32)`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD CONSTRAINT "FK_ab1bc0c1e209daa77b8e8d212ad" FOREIGN KEY ("proxyAccountId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP CONSTRAINT "FK_ab1bc0c1e209daa77b8e8d212ad"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "proxyAccountId"`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "proxyAccountId" character varying(128)`, undefined);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" RENAME COLUMN "proxyAccountId" TO "proxyAccount"`, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -100,10 +100,8 @@
|
||||||
<section class="_card">
|
<section class="_card">
|
||||||
<div class="_title"><fa :icon="faGhost"/> {{ $t('proxyAccount') }}</div>
|
<div class="_title"><fa :icon="faGhost"/> {{ $t('proxyAccount') }}</div>
|
||||||
<div class="_content">
|
<div class="_content">
|
||||||
<mk-input v-model="proxyAccount" style="margin: 0;"><template #prefix>@</template>{{ $t('proxyAccount') }}<template #desc>{{ $t('proxyAccountDescription') }}</template></mk-input>
|
<mk-input :value="proxyAccount ? proxyAccount.username : null" style="margin: 0;" disabled><template #prefix>@</template>{{ $t('proxyAccount') }}<template #desc>{{ $t('proxyAccountDescription') }}</template></mk-input>
|
||||||
</div>
|
<mk-button primary @click="chooseProxyAccount">{{ $t('chooseProxyAccount') }}</mk-button>
|
||||||
<div class="_footer">
|
|
||||||
<mk-button primary @click="save(true)"><fa :icon="faSave"/> {{ $t('save') }}</mk-button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -210,6 +208,7 @@ export default Vue.extend({
|
||||||
stats: null,
|
stats: null,
|
||||||
serverInfo: null,
|
serverInfo: null,
|
||||||
proxyAccount: null,
|
proxyAccount: null,
|
||||||
|
proxyAccountId: null,
|
||||||
cacheRemoteFiles: false,
|
cacheRemoteFiles: false,
|
||||||
proxyRemoteFiles: false,
|
proxyRemoteFiles: false,
|
||||||
localDriveCapacityMb: 0,
|
localDriveCapacityMb: 0,
|
||||||
|
@ -261,7 +260,7 @@ export default Vue.extend({
|
||||||
this.enableRecaptcha = this.meta.enableRecaptcha;
|
this.enableRecaptcha = this.meta.enableRecaptcha;
|
||||||
this.recaptchaSiteKey = this.meta.recaptchaSiteKey;
|
this.recaptchaSiteKey = this.meta.recaptchaSiteKey;
|
||||||
this.recaptchaSecretKey = this.meta.recaptchaSecretKey;
|
this.recaptchaSecretKey = this.meta.recaptchaSecretKey;
|
||||||
this.proxyAccount = this.meta.proxyAccount;
|
this.proxyAccountId = this.meta.proxyAccountId;
|
||||||
this.cacheRemoteFiles = this.meta.cacheRemoteFiles;
|
this.cacheRemoteFiles = this.meta.cacheRemoteFiles;
|
||||||
this.proxyRemoteFiles = this.meta.proxyRemoteFiles;
|
this.proxyRemoteFiles = this.meta.proxyRemoteFiles;
|
||||||
this.localDriveCapacityMb = this.meta.driveCapacityPerLocalUserMb;
|
this.localDriveCapacityMb = this.meta.driveCapacityPerLocalUserMb;
|
||||||
|
@ -280,6 +279,12 @@ export default Vue.extend({
|
||||||
this.enableDiscordIntegration = this.meta.enableDiscordIntegration;
|
this.enableDiscordIntegration = this.meta.enableDiscordIntegration;
|
||||||
this.discordClientId = this.meta.discordClientId;
|
this.discordClientId = this.meta.discordClientId;
|
||||||
this.discordClientSecret = this.meta.discordClientSecret;
|
this.discordClientSecret = this.meta.discordClientSecret;
|
||||||
|
|
||||||
|
if (this.proxyAccountId) {
|
||||||
|
this.$root.api('users/show', { userId: this.proxyAccountId }).then(proxyAccount => {
|
||||||
|
this.proxyAccount = proxyAccount;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$root.api('admin/server-info').then(res => {
|
this.$root.api('admin/server-info').then(res => {
|
||||||
|
@ -324,6 +329,14 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
chooseProxyAccount() {
|
||||||
|
this.$root.new(MkUserSelect, {}).$once('selected', user => {
|
||||||
|
this.proxyAccount = user;
|
||||||
|
this.proxyAccountId = user.id;
|
||||||
|
this.save(true);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
save(withDialog = false) {
|
save(withDialog = false) {
|
||||||
this.$root.api('admin/update-meta', {
|
this.$root.api('admin/update-meta', {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
|
@ -339,7 +352,7 @@ export default Vue.extend({
|
||||||
enableRecaptcha: this.enableRecaptcha,
|
enableRecaptcha: this.enableRecaptcha,
|
||||||
recaptchaSiteKey: this.recaptchaSiteKey,
|
recaptchaSiteKey: this.recaptchaSiteKey,
|
||||||
recaptchaSecretKey: this.recaptchaSecretKey,
|
recaptchaSecretKey: this.recaptchaSecretKey,
|
||||||
proxyAccount: this.proxyAccount,
|
proxyAccountId: this.proxyAccountId,
|
||||||
cacheRemoteFiles: this.cacheRemoteFiles,
|
cacheRemoteFiles: this.cacheRemoteFiles,
|
||||||
proxyRemoteFiles: this.proxyRemoteFiles,
|
proxyRemoteFiles: this.proxyRemoteFiles,
|
||||||
localDriveCapacityMb: parseInt(this.localDriveCapacityMb, 10),
|
localDriveCapacityMb: parseInt(this.localDriveCapacityMb, 10),
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { fetchMeta } from './fetch-meta';
|
import { fetchMeta } from './fetch-meta';
|
||||||
import { ILocalUser } from '../models/entities/user';
|
import { ILocalUser } from '../models/entities/user';
|
||||||
import { Users } from '../models';
|
import { Users } from '../models';
|
||||||
import { ensure } from '../prelude/ensure';
|
|
||||||
|
|
||||||
export async function fetchProxyAccount(): Promise<ILocalUser> {
|
export async function fetchProxyAccount(): Promise<ILocalUser | null> {
|
||||||
|
if (meta.proxyAccountId == null) return null;
|
||||||
const meta = await fetchMeta();
|
const meta = await fetchMeta();
|
||||||
return await Users.findOne({ username: meta.proxyAccount!, host: null }).then(ensure) as ILocalUser;
|
return await Users.findOne(meta.proxyAccountId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { Entity, Column, PrimaryColumn } from 'typeorm';
|
import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||||
|
import { User } from './user';
|
||||||
|
import { id } from '../id';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Meta {
|
export class Meta {
|
||||||
|
@ -110,11 +112,17 @@ export class Meta {
|
||||||
})
|
})
|
||||||
public proxyRemoteFiles: boolean;
|
public proxyRemoteFiles: boolean;
|
||||||
|
|
||||||
@Column('varchar', {
|
@Column({
|
||||||
length: 128,
|
...id(),
|
||||||
nullable: true
|
nullable: true,
|
||||||
})
|
})
|
||||||
public proxyAccount: string | null;
|
public proxyAccountId: User['id'] | null;
|
||||||
|
|
||||||
|
@ManyToOne(type => User, {
|
||||||
|
onDelete: 'SET NULL'
|
||||||
|
})
|
||||||
|
@JoinColumn()
|
||||||
|
public proxyAccount: User | null;
|
||||||
|
|
||||||
@Column('boolean', {
|
@Column('boolean', {
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { getConnection } from 'typeorm';
|
||||||
import { Meta } from '../../../../models/entities/meta';
|
import { Meta } from '../../../../models/entities/meta';
|
||||||
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
import { insertModerationLog } from '../../../../services/insert-moderation-log';
|
||||||
import { DB_MAX_NOTE_TEXT_LENGTH } from '../../../../misc/hard-limits';
|
import { DB_MAX_NOTE_TEXT_LENGTH } from '../../../../misc/hard-limits';
|
||||||
|
import { ID } from '../../../../misc/cafy-id';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -165,10 +166,10 @@ export const meta = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
proxyAccount: {
|
proxyAccountId: {
|
||||||
validator: $.optional.nullable.str,
|
validator: $.optional.nullable.type(ID),
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'プロキシアカウントのユーザー名'
|
'ja-JP': 'プロキシアカウントのID'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -479,8 +480,8 @@ export default define(meta, async (ps, me) => {
|
||||||
set.recaptchaSecretKey = ps.recaptchaSecretKey;
|
set.recaptchaSecretKey = ps.recaptchaSecretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.proxyAccount !== undefined) {
|
if (ps.proxyAccountId !== undefined) {
|
||||||
set.proxyAccount = ps.proxyAccount;
|
set.proxyAccountId = ps.proxyAccountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.maintainerName !== undefined) {
|
if (ps.maintainerName !== undefined) {
|
||||||
|
|
|
@ -170,7 +170,7 @@ export default define(meta, async (ps, me) => {
|
||||||
response.hiddenTags = instance.hiddenTags;
|
response.hiddenTags = instance.hiddenTags;
|
||||||
response.blockedHosts = instance.blockedHosts;
|
response.blockedHosts = instance.blockedHosts;
|
||||||
response.recaptchaSecretKey = instance.recaptchaSecretKey;
|
response.recaptchaSecretKey = instance.recaptchaSecretKey;
|
||||||
response.proxyAccount = instance.proxyAccount;
|
response.proxyAccountId = instance.proxyAccountId;
|
||||||
response.twitterConsumerKey = instance.twitterConsumerKey;
|
response.twitterConsumerKey = instance.twitterConsumerKey;
|
||||||
response.twitterConsumerSecret = instance.twitterConsumerSecret;
|
response.twitterConsumerSecret = instance.twitterConsumerSecret;
|
||||||
response.githubClientId = instance.githubClientId;
|
response.githubClientId = instance.githubClientId;
|
||||||
|
|
|
@ -22,7 +22,9 @@ export async function pushUserToUserList(target: User, list: UserList) {
|
||||||
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
|
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
|
||||||
if (Users.isRemoteUser(target)) {
|
if (Users.isRemoteUser(target)) {
|
||||||
const proxy = await fetchProxyAccount();
|
const proxy = await fetchProxyAccount();
|
||||||
const content = renderActivity(renderFollow(proxy, target));
|
if (proxy) {
|
||||||
deliver(proxy, content, target.inbox);
|
const content = renderActivity(renderFollow(proxy, target));
|
||||||
|
deliver(proxy, content, target.inbox);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue