mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-12-01 06:17:38 -07:00
特定インスタンスからのフォローを全解除できるように
This commit is contained in:
parent
fd1664cc4f
commit
3b6bbbd6b4
3 changed files with 58 additions and 0 deletions
|
@ -1381,6 +1381,8 @@ admin/views/federation.vue:
|
||||||
status: "ステータス"
|
status: "ステータス"
|
||||||
latest-request-sent-at: "直近のリクエスト送信"
|
latest-request-sent-at: "直近のリクエスト送信"
|
||||||
latest-request-received-at: "直近のリクエスト受信"
|
latest-request-received-at: "直近のリクエスト受信"
|
||||||
|
remove-all-following: "フォローを全解除"
|
||||||
|
remove-all-following-info: "{host}からのフォローをすべて解除します。そのインスタンスがもう存在しなくなった場合などに実行してください。"
|
||||||
lookup: "照会"
|
lookup: "照会"
|
||||||
instances: "インスタンス"
|
instances: "インスタンス"
|
||||||
instance-not-registered: "そのインスタンスは登録されていません"
|
instance-not-registered: "そのインスタンスは登録されていません"
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
<ui-input :value="instance.latestRequestReceivedAt" type="text" readonly>
|
<ui-input :value="instance.latestRequestReceivedAt" type="text" readonly>
|
||||||
<span>{{ $t('latest-request-received-at') }}</span>
|
<span>{{ $t('latest-request-received-at') }}</span>
|
||||||
</ui-input>
|
</ui-input>
|
||||||
|
<section>
|
||||||
|
<ui-button @click="removeAllFollowing()">{{ $t('remove-all-following') }}</ui-button>
|
||||||
|
<ui-info warn>{{ $t('remove-all-following-info', { host: instance.host }) }}</ui-info>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</ui-card>
|
</ui-card>
|
||||||
|
@ -138,6 +142,17 @@ export default Vue.extend({
|
||||||
}).then(instances => {
|
}).then(instances => {
|
||||||
this.instances = instances;
|
this.instances = instances;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
removeAllFollowing() {
|
||||||
|
this.$root.api('admin/federation/remove-all-following', {
|
||||||
|
host: this.instance.host
|
||||||
|
}).then(() => {
|
||||||
|
this.$root.dialog({
|
||||||
|
type: 'success',
|
||||||
|
splash: true
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
import $ from 'cafy';
|
||||||
|
import define from '../../../define';
|
||||||
|
import Instance from '../../../../../models/instance';
|
||||||
|
import Following from '../../../../../models/following';
|
||||||
|
import User from '../../../../../models/user';
|
||||||
|
import deleteFollowing from '../../../../../services/following/delete';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
requireCredential: true,
|
||||||
|
requireModerator: true,
|
||||||
|
|
||||||
|
params: {
|
||||||
|
host: {
|
||||||
|
validator: $.str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
|
const instance = await Instance
|
||||||
|
.findOne({ host: ps.host });
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
return rej('instance not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
const followings = await Following.find({
|
||||||
|
'_follower.host': { $ne: null }
|
||||||
|
});
|
||||||
|
|
||||||
|
const pairs = await Promise.all(followings.map(f => Promise.all([
|
||||||
|
User.findOne({ _id: f.followerId }),
|
||||||
|
User.findOne({ _id: f.followeeId })
|
||||||
|
])));
|
||||||
|
|
||||||
|
for (const pair of pairs) {
|
||||||
|
deleteFollowing(pair[0], pair[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
res();
|
||||||
|
}));
|
Loading…
Reference in a new issue