Commit 50f4703a authored by Julien Schröter's avatar Julien Schröter

Assign notification receiver on POST /duel/answer endpoint

parent bc7ce267
Pipeline #2009 passed with stage
in 11 minutes and 48 seconds
......@@ -360,24 +360,24 @@ func postAnswer(repository DuelQuery, titleRepository title.TitleQuery, sessionR
data := make(map[string]string)
data["duel"] = strconv.FormatUint(uint64(status.ID), 10)
// Duel has been finished. Send opponent whether he won.
var scoreOpponent, scorePlayer uint32
for id, score := range status.Scores {
if id == userID {
scorePlayer = score
} else {
scoreOpponent = score
receiver = id
}
}
if !status.Finished {
notificationType = notifications.DuelResponseNotificationType
notification = &messaging.Notification{
Title: fmt.Sprintf("%v hat gespielt.", username),
Body: "Spiele jetzt die nächste Runde!"}
data["type"] = string(notifications.DuelResponseNotificationType)
} else {
// Duel has been finished. Send opponent whether he won.
var scoreOpponent, scorePlayer uint32
for id, score := range status.Scores {
if id == userID {
scorePlayer = score
} else {
scoreOpponent = score
}
}
switch {
case scoreOpponent > scorePlayer:
notificationType = notifications.DuelWonNotificationType
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment