mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
Erster Discord Versuch
This commit is contained in:
26
ober.go
26
ober.go
@@ -435,6 +435,15 @@ func Register(ctx *fasthttp.RequestCtx) {
|
||||
ctx.SetStatusCode(fasthttp.StatusExpectationFailed)
|
||||
return
|
||||
}
|
||||
// check user discord id
|
||||
if register.DiscordID != 0 && discc != nil {
|
||||
_, err = discc.User(fmt.Sprint(register.DiscordID != 0))
|
||||
if err != nil {
|
||||
ctx.WriteString("Discord user id is kaputt")
|
||||
ctx.SetStatusCode(fasthttp.StatusExpectationFailed)
|
||||
return
|
||||
}
|
||||
}
|
||||
// REGISTER
|
||||
user := UserData{
|
||||
Username: register.Username,
|
||||
@@ -499,6 +508,16 @@ func RegisterUpdate(ctx *fasthttp.RequestCtx) {
|
||||
if regUpdate.Secret != "" {
|
||||
user.Secret = regUpdate.Secret
|
||||
}
|
||||
|
||||
// check user discord id
|
||||
if regUpdate.DiscordID != 0 && discc != nil {
|
||||
_, err = discc.User(fmt.Sprint(regUpdate.DiscordID))
|
||||
if err != nil {
|
||||
ctx.WriteString("Discord user id is kaputt")
|
||||
ctx.SetStatusCode(fasthttp.StatusExpectationFailed)
|
||||
return
|
||||
}
|
||||
}
|
||||
user.DiscordID = regUpdate.DiscordID
|
||||
|
||||
err = SaveUser(user)
|
||||
@@ -795,6 +814,7 @@ func processUpdateAppointmentReq(ctx *fasthttp.RequestCtx, update bool) {
|
||||
for i, appointment := range appoints {
|
||||
var appData *Appointment
|
||||
var found bool
|
||||
fresh := false
|
||||
|
||||
if update {
|
||||
// kann sich (noch) nicht in der Vergagenheit verabreden
|
||||
@@ -816,7 +836,7 @@ func processUpdateAppointmentReq(ctx *fasthttp.RequestCtx, update bool) {
|
||||
}
|
||||
|
||||
// save appointment and get list
|
||||
appData, err = AddUserToAppointment(username, appointment.Anime, appointment.Time)
|
||||
appData, fresh, err = AddUserToAppointment(username, appointment.Anime, appointment.Time)
|
||||
} else {
|
||||
found, err = CheckAnimeExistInDb(appointment.Anime)
|
||||
if err != nil {
|
||||
@@ -836,6 +856,10 @@ func processUpdateAppointmentReq(ctx *fasthttp.RequestCtx, update bool) {
|
||||
return
|
||||
}
|
||||
appoints[i].Users = appData.Users
|
||||
|
||||
if update && fresh {
|
||||
SendAppointBroadcast(username, appData)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(appoints)
|
||||
|
||||
Reference in New Issue
Block a user