paricafe/src/server/api/endpoints/admin/federation/update-instance.ts
syuilo 2756f553c6
Improve error handling of API (#4345)
* wip

* wip

* wip

* Update attached_notes.ts

* wip

* Refactor

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update call.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* ✌️

* Fix
2019-02-22 11:46:58 +09:00

39 lines
638 B
TypeScript

import $ from 'cafy';
import define from '../../../define';
import Instance from '../../../../../models/instance';
export const meta = {
requireCredential: true,
requireModerator: true,
params: {
host: {
validator: $.str
},
isBlocked: {
validator: $.bool
},
isClosed: {
validator: $.bool
},
}
};
export default define(meta, async (ps, me) => {
const instance = await Instance.findOne({ host: ps.host });
if (instance == null) {
throw new Error('instance not found');
}
Instance.update({ host: ps.host }, {
$set: {
isBlocked: ps.isBlocked,
isMarkedAsClosed: ps.isClosed
}
});
return;
});