major bug fixes & breaking change in database code

Major bug fixes and improvements have been made. There's also a breaking change for plugins using the database system. All database related functions are now async based.
This commit is contained in:
DJj123dj
2024-11-24 23:26:14 +01:00
parent 6b36b1caf6
commit b22f7b2de7
18 changed files with 141 additions and 118 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ export const loadAllBlacklistedUsers = async () => {
const userDatabase = openticket.databases.get("openticket:users")
if (!userDatabase) return
const users = userDatabase.getCategory("openticket:blacklist") ?? []
const users = await userDatabase.getCategory("openticket:blacklist") ?? []
users.forEach((user) => {
if (typeof user.value == "string" || user.value === null) openticket.blacklist.add(new api.ODBlacklist(user.key,user.value))
})
+1 -1
View File
@@ -6,7 +6,7 @@ export const loadAllTickets = async () => {
const ticketDatabase = openticket.databases.get("openticket:tickets")
if (!ticketDatabase) return
const tickets = ticketDatabase.getCategory("openticket:ticket")
const tickets = await ticketDatabase.getCategory("openticket:ticket")
if (!tickets) return
tickets.forEach((ticket) => {
try {
+4
View File
@@ -178,12 +178,16 @@ export const loadAllTranscriptCompilers = async () => {
const req = new api.ODHTTPGetRequest("https://apis.dj-dj.be/transcripts/status.json",false)
const res = await req.run()
if (!res || res.status != 200 || !res.body){
openticket.debugfile.writeNote("HTML Transcripts Error => status: "+res.status+", body:\n"+res.body)
process.emit("uncaughtException",new api.ODSystemError("HTML Transcripts INIT_COMMUNICATON error! (check otdebug.txt for details)"))
return {success:false,errorReason:"HTML Transcripts are currently unavailable!",pendingMessage:null}
}
try{
const data = JSON.parse(res.body)
if (!data || data["v2"] != "online") return {success:false,errorReason:"HTML Transcripts are currently unavailable due to maintenance!",pendingMessage:null}
}catch{
openticket.debugfile.writeNote("HTML Transcripts Error => unable to parse status! body:\n"+res.body)
process.emit("uncaughtException",new api.ODSystemError("HTML Transcripts INIT_STATUS_PARSE error! (check otdebug.txt for details)"))
return {success:false,errorReason:"HTML Transcripts are currently unavailable due to JSON parse error!",pendingMessage:null}
}