diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-02-08 20:56:16 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-02-08 20:56:16 +0900 |
| commit | 5e0eda9526d512344485a4ec642775ca04c2c1af (patch) | |
| tree | 90dd49e1a9ca318816305b8e35ff812d32b91163 /src | |
| parent | 10.83.0 (diff) | |
| download | misskey-5e0eda9526d512344485a4ec642775ca04c2c1af.tar.gz misskey-5e0eda9526d512344485a4ec642775ca04c2c1af.tar.bz2 misskey-5e0eda9526d512344485a4ec642775ca04c2c1af.zip | |
Improve instances manegement
Resolve #4187
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/app/admin/views/federation.vue | 12 | ||||
| -rw-r--r-- | src/models/instance.ts | 15 | ||||
| -rw-r--r-- | src/queue/processors/http/deliver.ts | 7 | ||||
| -rw-r--r-- | src/queue/processors/http/process-inbox.ts | 4 | ||||
| -rw-r--r-- | src/server/api/endpoints/admin/federation/update-instance.ts | 7 | ||||
| -rw-r--r-- | src/server/api/endpoints/federation/instances.ts | 26 |
6 files changed, 60 insertions, 11 deletions
diff --git a/src/client/app/admin/views/federation.vue b/src/client/app/admin/views/federation.vue index 8b0e9ba45a..b60ce89241 100644 --- a/src/client/app/admin/views/federation.vue +++ b/src/client/app/admin/views/federation.vue @@ -40,6 +40,7 @@ <span>{{ $t('latest-request-received-at') }}</span> </ui-input> <ui-switch v-model="instance.isBlocked" @change="updateInstance()">{{ $t('block') }}</ui-switch> + <ui-switch v-model="instance.isMarkedAsClosed" @change="updateInstance()">{{ $t('marked-as-closed') }}</ui-switch> <details> <summary>{{ $t('charts') }}</summary> <ui-horizon-group inputs> @@ -80,6 +81,8 @@ <span slot="label">{{ $t('sort') }}</span> <option value="-caughtAt">{{ $t('sorts.caughtAtAsc') }}</option> <option value="+caughtAt">{{ $t('sorts.caughtAtDesc') }}</option> + <option value="-lastCommunicatedAt">{{ $t('sorts.lastCommunicatedAtAsc') }}</option> + <option value="+lastCommunicatedAt">{{ $t('sorts.lastCommunicatedAtDesc') }}</option> <option value="-notes">{{ $t('sorts.notesAsc') }}</option> <option value="+notes">{{ $t('sorts.notesDesc') }}</option> <option value="-users">{{ $t('sorts.usersAsc') }}</option> @@ -97,6 +100,8 @@ <span slot="label">{{ $t('state') }}</span> <option value="all">{{ $t('states.all') }}</option> <option value="blocked">{{ $t('states.blocked') }}</option> + <option value="notResponding">{{ $t('states.not-responding') }}</option> + <option value="markedAsClosed">{{ $t('states.marked-as-closed') }}</option> </ui-select> </ui-horizon-group> @@ -247,7 +252,9 @@ export default Vue.extend({ fetchInstances() { this.instances = []; this.$root.api('federation/instances', { - state: this.state, + blocked: this.state === 'blocked' ? true : null, + notResponding: this.state === 'notResponding' ? true : null, + markedAsClosed: this.state === 'markedAsClosed' ? true : null, sort: this.sort, limit: this.limit }).then(instances => { @@ -269,7 +276,8 @@ export default Vue.extend({ updateInstance() { this.$root.api('admin/federation/update-instance', { host: this.instance.host, - isBlocked: this.instance.isBlocked, + isBlocked: this.instance.isBlocked || false, + isClosed: this.instance.isMarkedAsClosed || false }); }, diff --git a/src/models/instance.ts b/src/models/instance.ts index 985564f8de..cdce570a4b 100644 --- a/src/models/instance.ts +++ b/src/models/instance.ts @@ -69,7 +69,22 @@ export interface IInstance { latestRequestReceivedAt?: Date; /** + * このインスタンスと不通かどうか + */ + isNotResponding: boolean; + + /** + * このインスタンスと最後にやり取りした日時 + */ + lastCommunicatedAt: Date; + + /** * このインスタンスをブロックしているか */ isBlocked: boolean; + + /** + * このインスタンスが閉鎖済みとしてマークされているか + */ + isMarkedAsClosed: boolean; } diff --git a/src/queue/processors/http/deliver.ts b/src/queue/processors/http/deliver.ts index 6d24cd2634..1ba582a284 100644 --- a/src/queue/processors/http/deliver.ts +++ b/src/queue/processors/http/deliver.ts @@ -17,7 +17,9 @@ export default async (job: bq.Job, done: any): Promise<void> => { Instance.update({ _id: i._id }, { $set: { latestRequestSentAt: new Date(), - latestStatus: 200 + latestStatus: 200, + lastCommunicatedAt: new Date(), + isNotResponding: false } }); @@ -31,7 +33,8 @@ export default async (job: bq.Job, done: any): Promise<void> => { Instance.update({ _id: i._id }, { $set: { latestRequestSentAt: new Date(), - latestStatus: res != null && res.hasOwnProperty('statusCode') ? res.statusCode : null + latestStatus: res != null && res.hasOwnProperty('statusCode') ? res.statusCode : null, + isNotResponding: true } }); diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts index 07d4b5ba71..43170848f9 100644 --- a/src/queue/processors/http/process-inbox.ts +++ b/src/queue/processors/http/process-inbox.ts @@ -126,7 +126,9 @@ export default async (job: bq.Job, done: any): Promise<void> => { registerOrFetchInstanceDoc(user.host).then(i => { Instance.update({ _id: i._id }, { $set: { - latestRequestReceivedAt: new Date() + latestRequestReceivedAt: new Date(), + lastCommunicatedAt: new Date(), + isNotResponding: false } }); diff --git a/src/server/api/endpoints/admin/federation/update-instance.ts b/src/server/api/endpoints/admin/federation/update-instance.ts index de40480a49..579b437aa1 100644 --- a/src/server/api/endpoints/admin/federation/update-instance.ts +++ b/src/server/api/endpoints/admin/federation/update-instance.ts @@ -14,6 +14,10 @@ export const meta = { isBlocked: { validator: $.bool }, + + isClosed: { + validator: $.bool + }, } }; @@ -26,7 +30,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { Instance.update({ host: ps.host }, { $set: { - isBlocked: ps.isBlocked + isBlocked: ps.isBlocked, + isMarkedAsClosed: ps.isClosed } }); diff --git a/src/server/api/endpoints/federation/instances.ts b/src/server/api/endpoints/federation/instances.ts index 9b4efbaaff..9c1e57ee16 100644 --- a/src/server/api/endpoints/federation/instances.ts +++ b/src/server/api/endpoints/federation/instances.ts @@ -6,8 +6,16 @@ export const meta = { requireCredential: false, params: { - state: { - validator: $.str.optional, + blocked: { + validator: $.bool.optional.nullable, + }, + + notResponding: { + validator: $.bool.optional.nullable, + }, + + markedAsClosed: { + validator: $.bool.optional.nullable, }, limit: { @@ -70,6 +78,14 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { sort = { caughtAt: 1 }; + } else if (ps.sort == '+lastCommunicatedAt') { + sort = { + lastCommunicatedAt: -1 + }; + } else if (ps.sort == '-lastCommunicatedAt') { + sort = { + lastCommunicatedAt: 1 + }; } else if (ps.sort == '+driveUsage') { sort = { driveUsage: -1 @@ -95,9 +111,9 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { const q = {} as any; - if (ps.state === 'blocked') { - q.isBlocked = true; - } + if (typeof ps.blocked === 'boolean') q.isBlocked = ps.blocked; + if (typeof ps.notResponding === 'boolean') q.isNotResponding = ps.notResponding; + if (typeof ps.markedAsClosed === 'boolean') q.isMarkedAsClosed = ps.markedAsClosed; const instances = await Instance .find(q, { |