mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-13 05:00:45 +01:00
ghostの設定をDBに保存するように
This commit is contained in:
parent
87d4452d19
commit
2de48110bb
9 changed files with 55 additions and 21 deletions
|
@ -135,11 +135,6 @@ autoAdmin: true
|
||||||
# client_id: example-github-client-id
|
# client_id: example-github-client-id
|
||||||
# client_secret: example-github-client-secret
|
# client_secret: example-github-client-secret
|
||||||
|
|
||||||
# Ghost
|
|
||||||
# Ghost account is an account used for the purpose of delegating
|
|
||||||
# followers when putting users in the list.
|
|
||||||
#ghost: user-id-of-your-ghost-account
|
|
||||||
|
|
||||||
# Clustering
|
# Clustering
|
||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
|
|
|
@ -1090,6 +1090,11 @@ admin/views/instance.vue:
|
||||||
enable-recaptcha: "reCAPTCHAを有効にする"
|
enable-recaptcha: "reCAPTCHAを有効にする"
|
||||||
recaptcha-site-key: "reCAPTCHA site key"
|
recaptcha-site-key: "reCAPTCHA site key"
|
||||||
recaptcha-secret-key: "reCAPTCHA secret key"
|
recaptcha-secret-key: "reCAPTCHA secret key"
|
||||||
|
proxy-account-config: "プロキシアカウントの設定"
|
||||||
|
proxy-account-info: "プロキシアカウントは、特定の条件下でユーザーのリモートフォローを代行するアカウントです。例えば、ユーザーがリモートユーザーをリストに入れたとき、リストに入れられたユーザーを誰もフォローしていないとアクティビティがサーバーに配達されないため、代わりにプロキシアカウントがフォローするようにします。"
|
||||||
|
proxy-account-username: "プロキシアカウントのユーザー名"
|
||||||
|
proxy-account-username-desc: "プロキシとして使用するアカウントのユーザー名を指定してください。"
|
||||||
|
proxy-account-warn: "アカウントは自動で作られないため、そのユーザー名のアカウントを予め作成しておく必要があります。"
|
||||||
max-note-text-length: "投稿の最大文字数"
|
max-note-text-length: "投稿の最大文字数"
|
||||||
disable-registration: "ユーザー登録の受付を停止する"
|
disable-registration: "ユーザー登録の受付を停止する"
|
||||||
disable-local-timeline: "ローカルタイムラインを無効にする"
|
disable-local-timeline: "ローカルタイムラインを無効にする"
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
<section class="fit-bottom">
|
<section class="fit-bottom">
|
||||||
<header><fa icon="cloud"/> %i18n:@drive-config%</header>
|
<header><fa icon="cloud"/> %i18n:@drive-config%</header>
|
||||||
<ui-switch v-model="cacheRemoteFiles">%i18n:@cache-remote-files%<span slot="desc">%i18n:@cache-remote-files-desc%</span></ui-switch>
|
<ui-switch v-model="cacheRemoteFiles">%i18n:@cache-remote-files%<span slot="desc">%i18n:@cache-remote-files-desc%</span></ui-switch>
|
||||||
<ui-input v-model="localDriveCapacityMb">%i18n:@local-drive-capacity-mb%<span slot="desc">%i18n:@mb%</span><span slot="suffix">MB</span></ui-input>
|
<ui-input v-model="localDriveCapacityMb">%i18n:@local-drive-capacity-mb%<span slot="suffix">MB</span><span slot="desc">%i18n:@mb%</span></ui-input>
|
||||||
<ui-input v-model="remoteDriveCapacityMb" :disabled="!cacheRemoteFiles">%i18n:@remote-drive-capacity-mb%<span slot="desc">%i18n:@mb%</span><span slot="suffix">MB</span></ui-input>
|
<ui-input v-model="remoteDriveCapacityMb" :disabled="!cacheRemoteFiles">%i18n:@remote-drive-capacity-mb%<span slot="suffix">MB</span><span slot="desc">%i18n:@mb%</span></ui-input>
|
||||||
</section>
|
</section>
|
||||||
<section class="fit-bottom">
|
<section class="fit-bottom">
|
||||||
<header><fa icon="shield-alt"/> %i18n:@recaptcha-config%</header>
|
<header><fa icon="shield-alt"/> %i18n:@recaptcha-config%</header>
|
||||||
|
@ -23,6 +23,12 @@
|
||||||
<ui-input v-model="recaptchaSiteKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-site-key%</ui-input>
|
<ui-input v-model="recaptchaSiteKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-site-key%</ui-input>
|
||||||
<ui-input v-model="recaptchaSecretKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-secret-key%</ui-input>
|
<ui-input v-model="recaptchaSecretKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-secret-key%</ui-input>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<header><fa icon="ghost"/> %i18n:@proxy-account-config%</header>
|
||||||
|
<ui-info>%i18n:@proxy-account-info%</ui-info>
|
||||||
|
<ui-input v-model="proxyAccount"><i slot="prefix">@</i>%i18n:@proxy-account-username%<span slot="desc">%i18n:@proxy-account-username-desc%</span></ui-input>
|
||||||
|
<ui-info warn>%i18n:@proxy-account-warn%</ui-info>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<ui-switch v-model="disableRegistration">%i18n:@disable-registration%</ui-switch>
|
<ui-switch v-model="disableRegistration">%i18n:@disable-registration%</ui-switch>
|
||||||
</section>
|
</section>
|
||||||
|
@ -62,6 +68,7 @@ export default Vue.extend({
|
||||||
enableRecaptcha: false,
|
enableRecaptcha: false,
|
||||||
recaptchaSiteKey: null,
|
recaptchaSiteKey: null,
|
||||||
recaptchaSecretKey: null,
|
recaptchaSecretKey: null,
|
||||||
|
proxyAccount: null,
|
||||||
inviteCode: null,
|
inviteCode: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -78,6 +85,7 @@ export default Vue.extend({
|
||||||
this.enableRecaptcha = meta.enableRecaptcha;
|
this.enableRecaptcha = meta.enableRecaptcha;
|
||||||
this.recaptchaSiteKey = meta.recaptchaSiteKey;
|
this.recaptchaSiteKey = meta.recaptchaSiteKey;
|
||||||
this.recaptchaSecretKey = meta.recaptchaSecretKey;
|
this.recaptchaSecretKey = meta.recaptchaSecretKey;
|
||||||
|
this.proxyAccount = meta.proxyAccount;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -106,7 +114,8 @@ export default Vue.extend({
|
||||||
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10),
|
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10),
|
||||||
enableRecaptcha: this.enableRecaptcha,
|
enableRecaptcha: this.enableRecaptcha,
|
||||||
recaptchaSiteKey: this.recaptchaSiteKey,
|
recaptchaSiteKey: this.recaptchaSiteKey,
|
||||||
recaptchaSecretKey: this.recaptchaSecretKey
|
recaptchaSecretKey: this.recaptchaSecretKey,
|
||||||
|
proxyAccount: this.proxyAccount,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$swal({
|
this.$swal({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|
|
@ -50,11 +50,6 @@ export type Source = {
|
||||||
|
|
||||||
autoAdmin?: boolean;
|
autoAdmin?: boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* ゴーストアカウントのID
|
|
||||||
*/
|
|
||||||
ghost?: string;
|
|
||||||
|
|
||||||
proxy?: string;
|
proxy?: string;
|
||||||
|
|
||||||
summalyProxy?: string;
|
summalyProxy?: string;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
import User from './user';
|
||||||
|
import { transform } from '../misc/cafy-id';
|
||||||
|
|
||||||
const Meta = db.get<IMeta>('meta');
|
const Meta = db.get<IMeta>('meta');
|
||||||
export default Meta;
|
export default Meta;
|
||||||
|
@ -74,6 +76,18 @@ if ((config as any).recaptcha) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if ((config as any).ghost) {
|
||||||
|
Meta.findOne({}).then(async m => {
|
||||||
|
if (m != null && m.proxyAccount == null) {
|
||||||
|
const account = await User.findOne({ _id: transform((config as any).ghost) });
|
||||||
|
Meta.update({}, {
|
||||||
|
$set: {
|
||||||
|
proxyAccount: account.username
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export type IMeta = {
|
export type IMeta = {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
@ -92,6 +106,8 @@ export type IMeta = {
|
||||||
|
|
||||||
cacheRemoteFiles?: boolean;
|
cacheRemoteFiles?: boolean;
|
||||||
|
|
||||||
|
proxyAccount?: string;
|
||||||
|
|
||||||
enableRecaptcha?: boolean;
|
enableRecaptcha?: boolean;
|
||||||
recaptchaSiteKey?: string;
|
recaptchaSiteKey?: string;
|
||||||
recaptchaSecretKey?: string;
|
recaptchaSecretKey?: string;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Mute from './mute';
|
||||||
import { getFriendIds } from '../server/api/common/get-friends';
|
import { getFriendIds } from '../server/api/common/get-friends';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import FollowRequest from './follow-request';
|
import FollowRequest from './follow-request';
|
||||||
|
import fetchMeta from '../misc/fetch-meta';
|
||||||
|
|
||||||
const User = db.get<IUser>('users');
|
const User = db.get<IUser>('users');
|
||||||
|
|
||||||
|
@ -376,6 +377,7 @@ function img(url) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getGhost(): Promise<ILocalUser> {
|
export async function fetchProxyAccount(): Promise<ILocalUser> {
|
||||||
return User.findOne({ _id: new mongo.ObjectId(config.ghost) });
|
const meta = await fetchMeta();
|
||||||
|
return await User.findOne({ username: meta.proxyAccount, host: null }) as ILocalUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,17 +98,24 @@ export const meta = {
|
||||||
},
|
},
|
||||||
|
|
||||||
recaptchaSiteKey: {
|
recaptchaSiteKey: {
|
||||||
validator: $.str.optional,
|
validator: $.str.optional.nullable,
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'reCAPTCHA site key'
|
'ja-JP': 'reCAPTCHA site key'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
recaptchaSecretKey: {
|
recaptchaSecretKey: {
|
||||||
validator: $.str.optional,
|
validator: $.str.optional.nullable,
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'reCAPTCHA secret key'
|
'ja-JP': 'reCAPTCHA secret key'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
proxyAccount: {
|
||||||
|
validator: $.str.optional.nullable,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': 'Proxy account username'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -172,6 +179,10 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||||
set.recaptchaSecretKey = ps.recaptchaSecretKey;
|
set.recaptchaSecretKey = ps.recaptchaSecretKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps.proxyAccount !== undefined) {
|
||||||
|
set.proxyAccount = ps.proxyAccount;
|
||||||
|
}
|
||||||
|
|
||||||
await Meta.update({}, {
|
await Meta.update({}, {
|
||||||
$set: set
|
$set: set
|
||||||
}, { upsert: true });
|
}, { upsert: true });
|
||||||
|
|
|
@ -85,6 +85,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
if (me && me.isAdmin) {
|
if (me && me.isAdmin) {
|
||||||
response.hidedTags = instance.hidedTags;
|
response.hidedTags = instance.hidedTags;
|
||||||
response.recaptchaSecretKey = instance.recaptchaSecretKey;
|
response.recaptchaSecretKey = instance.recaptchaSecretKey;
|
||||||
|
response.proxyAccount = instance.proxyAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
res(response);
|
res(response);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||||
import UserList from '../../../../../models/user-list';
|
import UserList from '../../../../../models/user-list';
|
||||||
import User, { pack as packUser, isRemoteUser, getGhost } from '../../../../../models/user';
|
import User, { pack as packUser, isRemoteUser, fetchProxyAccount } from '../../../../../models/user';
|
||||||
import { publishUserListStream } from '../../../../../stream';
|
import { publishUserListStream } from '../../../../../stream';
|
||||||
import ap from '../../../../../remote/activitypub/renderer';
|
import ap from '../../../../../remote/activitypub/renderer';
|
||||||
import renderFollow from '../../../../../remote/activitypub/renderer/follow';
|
import renderFollow from '../../../../../remote/activitypub/renderer/follow';
|
||||||
|
@ -71,8 +71,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
|
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
|
||||||
if (isRemoteUser(user)) {
|
if (isRemoteUser(user)) {
|
||||||
const ghost = await getGhost();
|
const proxy = await fetchProxyAccount();
|
||||||
const content = ap(renderFollow(ghost, user));
|
const content = ap(renderFollow(proxy, user));
|
||||||
deliver(ghost, content, user.inbox);
|
deliver(proxy, content, user.inbox);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue