-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,299 additions
and
1,315 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,96 @@ | ||
interface Community { | ||
id: number; | ||
platform: number; | ||
community_id: string; | ||
communityID?: string; | ||
discord_log_channel?: string; | ||
discord_notify_target?: string; | ||
id: number; | ||
platform: number; | ||
community_id: string; | ||
communityID?: string; | ||
discord_log_channel?: string; | ||
discord_notify_target?: string; | ||
} | ||
|
||
export default class Communities { | ||
static url = `${process.env.BACKEND_URL!}/community`; | ||
static url = `${process.env.BACKEND_URL!}/community`; | ||
|
||
static async create(communityID: string): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify({ communityID }), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`POST ${this.url}: ${response.status} ${response.statusText}` | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async create(communityID: string): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify({ communityID }), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`POST ${this.url}: ${response.status} ${response.statusText}`, | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
static async read(communityID: string): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`GET ${this.url}?id=${communityID}: ${response.status} ${response.statusText}` | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async read(communityID: string): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`GET ${this.url}?id=${communityID}: ${response.status} ${response.statusText}`, | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
static async update( | ||
data: Partial<Community> | ||
): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "PUT", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`PUT ${this.url}: ${response.status} ${response.statusText}` | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async update( | ||
data: Partial<Community>, | ||
): Promise<Community | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "PUT", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`PUT ${this.url}: ${response.status} ${response.statusText}`, | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
static async delete(communityID: string) { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "DELETE", | ||
headers: { | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`DELETE ${this.url}?id=${communityID}: ${response.status} ${response.statusText}` | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async delete(communityID: string) { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "DELETE", | ||
headers: { | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`DELETE ${this.url}?id=${communityID}: ${response.status} ${response.statusText}`, | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,88 @@ | ||
export interface MemberDominator { | ||
id: number; | ||
community: number; | ||
communityID?: string; | ||
id: number; | ||
community: number; | ||
communityID?: string; | ||
|
||
crime_coefficient_100_action: number; | ||
crime_coefficient_300_action: number; | ||
toxicity_action: number; | ||
toxicity_threshold: number; | ||
severe_toxicity_action: number; | ||
severe_toxicity_threshold: number; | ||
identity_attack_action: number; | ||
identity_attack_threshold: number; | ||
insult_action: number; | ||
insult_threshold: number; | ||
threat_action: number; | ||
threat_threshold: number; | ||
profanity_action: number; | ||
profanity_threshold: number; | ||
sexually_explicit_action: number; | ||
sexually_explicit_threshold: number; | ||
crime_coefficient_100_action: number; | ||
crime_coefficient_300_action: number; | ||
toxicity_action: number; | ||
toxicity_threshold: number; | ||
severe_toxicity_action: number; | ||
severe_toxicity_threshold: number; | ||
identity_attack_action: number; | ||
identity_attack_threshold: number; | ||
insult_action: number; | ||
insult_threshold: number; | ||
threat_action: number; | ||
threat_threshold: number; | ||
profanity_action: number; | ||
profanity_threshold: number; | ||
sexually_explicit_action: number; | ||
sexually_explicit_threshold: number; | ||
} | ||
|
||
export class MemberDominators { | ||
static url = `${process.env.BACKEND_URL!}/dominator/member`; | ||
static url = `${process.env.BACKEND_URL!}/dominator/member`; | ||
|
||
static async read( | ||
communityID: string | ||
): Promise<MemberDominator | undefined> { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`GET ${this.url}?id=${communityID}: ${response.status} ${response.statusText}` | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async read(communityID: string): Promise<MemberDominator | undefined> { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`GET ${this.url}?id=${communityID}: ${response.status} ${response.statusText}`, | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
static async update( | ||
data: Partial<MemberDominator> | ||
): Promise<MemberDominator | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "PUT", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`PUT ${this.url}: ${response.status} ${response.statusText}` | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async update( | ||
data: Partial<MemberDominator>, | ||
): Promise<MemberDominator | undefined> { | ||
try { | ||
const response = await fetch(this.url, { | ||
method: "PUT", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`PUT ${this.url}: ${response.status} ${response.statusText}`, | ||
); | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
static async delete(communityID: string) { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "DELETE", | ||
headers: { | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`DELETE ${this.url}?id=${communityID}: ${response.status} ${response.statusText}` | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
static async delete(communityID: string) { | ||
try { | ||
const response = await fetch(`${this.url}?id=${communityID}`, { | ||
method: "DELETE", | ||
headers: { | ||
"User-Agent": `${process.env.npm_package_name}/${process.env.npm_package_version!} node.js/${process.version}`, | ||
Authorization: `Token ${process.env.BACKEND_API_KEY!}`, | ||
}, | ||
}); | ||
if (!response.ok) | ||
throw new Error( | ||
`DELETE ${this.url}?id=${communityID}: ${response.status} ${response.statusText}`, | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
} |
Oops, something went wrong.