特定のインスタンスのファイルをすべて削除できるように

This commit is contained in:
syuilo 2019-05-14 21:08:35 +09:00
parent 811f9c22d7
commit b779ff08e0
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
3 changed files with 45 additions and 2 deletions

View file

@ -1441,6 +1441,7 @@ admin/views/federation.vue:
latest-request-received-at: "直近のリクエスト受信" latest-request-received-at: "直近のリクエスト受信"
remove-all-following: "フォローを全解除" remove-all-following: "フォローを全解除"
remove-all-following-info: "{host}からのフォローをすべて解除します。そのインスタンスがもう存在しなくなった場合などに実行してください。" remove-all-following-info: "{host}からのフォローをすべて解除します。そのインスタンスがもう存在しなくなった場合などに実行してください。"
delete-all-files: "ファイルをすべて削除"
block: "ブロック" block: "ブロック"
marked-as-closed: "閉鎖されているとマーク" marked-as-closed: "閉鎖されているとマーク"
lookup: "照会" lookup: "照会"

View file

@ -78,6 +78,10 @@
</ui-horizon-group> </ui-horizon-group>
<div ref="chart"></div> <div ref="chart"></div>
</details> </details>
<details>
<summary>{{ $t('delete-all-files') }}</summary>
<ui-button @click="deleteAllFiles()" style="margin-top: 16px;"><fa :icon="faTrashAlt"/> {{ $t('delete-all-files') }}</ui-button>
</details>
<details> <details>
<summary>{{ $t('remove-all-following') }}</summary> <summary>{{ $t('remove-all-following') }}</summary>
<ui-button @click="removeAllFollowing()" style="margin-top: 16px;"><fa :icon="faMinusCircle"/> {{ $t('remove-all-following') }}</ui-button> <ui-button @click="removeAllFollowing()" style="margin-top: 16px;"><fa :icon="faMinusCircle"/> {{ $t('remove-all-following') }}</ui-button>
@ -158,7 +162,7 @@
import Vue from 'vue'; import Vue from 'vue';
import i18n from '../../i18n'; import i18n from '../../i18n';
import { faPaperPlane } from '@fortawesome/free-regular-svg-icons'; import { faPaperPlane } from '@fortawesome/free-regular-svg-icons';
import { faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faTrafficLight, faInbox } from '@fortawesome/free-solid-svg-icons'; import { faTrashAlt, faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faTrafficLight, faInbox } from '@fortawesome/free-solid-svg-icons';
import ApexCharts from 'apexcharts'; import ApexCharts from 'apexcharts';
import * as tinycolor from 'tinycolor2'; import * as tinycolor from 'tinycolor2';
@ -186,7 +190,7 @@ export default Vue.extend({
chartSpan: 'hour', chartSpan: 'hour',
chartInstance: null, chartInstance: null,
blockedHosts: '', blockedHosts: '',
faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faPaperPlane, faTrafficLight, faInbox faTrashAlt, faBan, faGlobe, faTerminal, faSearch, faMinusCircle, faServer, faCrosshairs, faEnvelopeOpenText, faUsers, faCaretDown, faCaretUp, faPaperPlane, faTrafficLight, faInbox
}; };
}, },
@ -307,6 +311,17 @@ export default Vue.extend({
}); });
}, },
deleteAllFiles() {
this.$root.api('admin/federation/delete-all-files', {
host: this.instance.host
}).then(() => {
this.$root.dialog({
type: 'success',
splash: true
});
});
},
updateInstance() { updateInstance() {
this.$root.api('admin/federation/update-instance', { this.$root.api('admin/federation/update-instance', {
host: this.instance.host, host: this.instance.host,

View file

@ -0,0 +1,27 @@
import $ from 'cafy';
import define from '../../../define';
import del from '../../../../../services/drive/delete-file';
import { DriveFiles } from '../../../../../models';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
params: {
host: {
validator: $.str
}
}
};
export default define(meta, async (ps, me) => {
const files = await DriveFiles.find({
userHost: ps.host
});
for (const file of files) {
del(file);
}
});