Implement instance blocking (#4182)
* Implement instance blocking * Add missing text * Delete unnecessary file * Covert Punycode to Unicode
This commit is contained in:
parent
5a28632af7
commit
e6612f610c
7 changed files with 105 additions and 4 deletions
34
src/server/api/endpoints/admin/federation/update-instance.ts
Normal file
34
src/server/api/endpoints/admin/federation/update-instance.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
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
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
Instance.update({ host: ps.host }, {
|
||||
$set: {
|
||||
isBlocked: ps.isBlocked
|
||||
}
|
||||
});
|
||||
|
||||
res();
|
||||
}));
|
Loading…
Add table
Add a link
Reference in a new issue