2020-01-31 10:56:52 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-10-12 09:26:04 -04:00
|
|
|
|
2018-11-19 11:36:20 -05:00
|
|
|
import { makeGetRequest, makeDeleteRequest, makePostBodyRequest } from '../requests/requests'
|
2020-12-07 08:32:36 -05:00
|
|
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
2018-10-12 09:26:04 -04:00
|
|
|
|
|
|
|
function getAccountBlocklistByAccount (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
start: number,
|
|
|
|
count: number,
|
|
|
|
sort = '-createdAt',
|
2020-12-07 08:32:36 -05:00
|
|
|
statusCodeExpected = HttpStatusCode.OK_200
|
2018-10-12 09:26:04 -04:00
|
|
|
) {
|
|
|
|
const path = '/api/v1/users/me/blocklist/accounts'
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
query: { start, count, sort },
|
|
|
|
path,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function addAccountToAccountBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
accountToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-12 09:26:04 -04:00
|
|
|
const path = '/api/v1/users/me/blocklist/accounts'
|
|
|
|
|
|
|
|
return makePostBodyRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
fields: {
|
|
|
|
accountName: accountToBlock
|
|
|
|
},
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function removeAccountFromAccountBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
accountToUnblock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-12 09:26:04 -04:00
|
|
|
const path = '/api/v1/users/me/blocklist/accounts/' + accountToUnblock
|
|
|
|
|
|
|
|
return makeDeleteRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getServerBlocklistByAccount (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
start: number,
|
|
|
|
count: number,
|
|
|
|
sort = '-createdAt',
|
2020-12-07 08:32:36 -05:00
|
|
|
statusCodeExpected = HttpStatusCode.OK_200
|
2018-10-12 09:26:04 -04:00
|
|
|
) {
|
|
|
|
const path = '/api/v1/users/me/blocklist/servers'
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
query: { start, count, sort },
|
|
|
|
path,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function addServerToAccountBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
serverToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-12 09:26:04 -04:00
|
|
|
const path = '/api/v1/users/me/blocklist/servers'
|
|
|
|
|
|
|
|
return makePostBodyRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
fields: {
|
|
|
|
host: serverToBlock
|
|
|
|
},
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function removeServerFromAccountBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
serverToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-12 09:26:04 -04:00
|
|
|
const path = '/api/v1/users/me/blocklist/servers/' + serverToBlock
|
|
|
|
|
|
|
|
return makeDeleteRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-10-15 07:03:04 -04:00
|
|
|
function getAccountBlocklistByServer (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
start: number,
|
|
|
|
count: number,
|
|
|
|
sort = '-createdAt',
|
2020-12-07 08:32:36 -05:00
|
|
|
statusCodeExpected = HttpStatusCode.OK_200
|
2018-10-15 07:03:04 -04:00
|
|
|
) {
|
|
|
|
const path = '/api/v1/server/blocklist/accounts'
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
query: { start, count, sort },
|
|
|
|
path,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function addAccountToServerBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
accountToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-15 07:03:04 -04:00
|
|
|
const path = '/api/v1/server/blocklist/accounts'
|
|
|
|
|
|
|
|
return makePostBodyRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
fields: {
|
|
|
|
accountName: accountToBlock
|
|
|
|
},
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function removeAccountFromServerBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
accountToUnblock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-15 07:03:04 -04:00
|
|
|
const path = '/api/v1/server/blocklist/accounts/' + accountToUnblock
|
|
|
|
|
|
|
|
return makeDeleteRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getServerBlocklistByServer (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
start: number,
|
|
|
|
count: number,
|
|
|
|
sort = '-createdAt',
|
2020-12-07 08:32:36 -05:00
|
|
|
statusCodeExpected = HttpStatusCode.OK_200
|
2018-10-15 07:03:04 -04:00
|
|
|
) {
|
|
|
|
const path = '/api/v1/server/blocklist/servers'
|
|
|
|
|
|
|
|
return makeGetRequest({
|
|
|
|
url,
|
|
|
|
token,
|
|
|
|
query: { start, count, sort },
|
|
|
|
path,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function addServerToServerBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
serverToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-15 07:03:04 -04:00
|
|
|
const path = '/api/v1/server/blocklist/servers'
|
|
|
|
|
|
|
|
return makePostBodyRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
fields: {
|
|
|
|
host: serverToBlock
|
|
|
|
},
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-07 08:32:36 -05:00
|
|
|
function removeServerFromServerBlocklist (
|
|
|
|
url: string,
|
|
|
|
token: string,
|
|
|
|
serverToBlock: string,
|
|
|
|
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
|
|
|
|
) {
|
2018-10-15 07:03:04 -04:00
|
|
|
const path = '/api/v1/server/blocklist/servers/' + serverToBlock
|
|
|
|
|
|
|
|
return makeDeleteRequest({
|
|
|
|
url,
|
|
|
|
path,
|
|
|
|
token,
|
|
|
|
statusCodeExpected
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-10-12 09:26:04 -04:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
getAccountBlocklistByAccount,
|
|
|
|
addAccountToAccountBlocklist,
|
|
|
|
removeAccountFromAccountBlocklist,
|
|
|
|
getServerBlocklistByAccount,
|
|
|
|
addServerToAccountBlocklist,
|
2018-10-15 07:03:04 -04:00
|
|
|
removeServerFromAccountBlocklist,
|
|
|
|
|
|
|
|
getAccountBlocklistByServer,
|
|
|
|
addAccountToServerBlocklist,
|
|
|
|
removeAccountFromServerBlocklist,
|
|
|
|
getServerBlocklistByServer,
|
|
|
|
addServerToServerBlocklist,
|
|
|
|
removeServerFromServerBlocklist
|
2018-10-12 09:26:04 -04:00
|
|
|
}
|