kopia lustrzana https://codeberg.org/nmkj/audon
fix cohost redirect
rodzic
8dc11e7f84
commit
db42f13ee4
26
user.go
26
user.go
|
@ -83,6 +83,7 @@ func redirectUserHandler(c echo.Context) error {
|
||||||
opts := options.FindOne().SetSort(bson.D{{Key: "created_at", Value: -1}})
|
opts := options.FindOne().SetSort(bson.D{{Key: "created_at", Value: -1}})
|
||||||
var room Room
|
var room Room
|
||||||
|
|
||||||
|
searchCohost := false
|
||||||
if err := coll.FindOne(c.Request().Context(), bson.D{
|
if err := coll.FindOne(c.Request().Context(), bson.D{
|
||||||
{Key: "host.audon_id", Value: user.AudonID},
|
{Key: "host.audon_id", Value: user.AudonID},
|
||||||
}, opts).Decode(&room); err == nil {
|
}, opts).Decode(&room); err == nil {
|
||||||
|
@ -90,16 +91,21 @@ func redirectUserHandler(c echo.Context) error {
|
||||||
// redirect to the hosting room if online
|
// redirect to the hosting room if online
|
||||||
return c.Redirect(http.StatusFound, fmt.Sprintf("/r/%s", room.RoomID))
|
return c.Redirect(http.StatusFound, fmt.Sprintf("/r/%s", room.RoomID))
|
||||||
} else {
|
} else {
|
||||||
// redirect to the first cohosting room if online
|
searchCohost = true
|
||||||
status, err := user.GetCurrentRoomStatus(c.Request().Context())
|
}
|
||||||
if err != nil {
|
} else {
|
||||||
c.Logger().Error(err)
|
searchCohost = true
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError)
|
}
|
||||||
}
|
if searchCohost {
|
||||||
for _, v := range status {
|
// redirect to the first cohosting room if online
|
||||||
if v.Role == "cohost" {
|
status, err := user.GetCurrentRoomStatus(c.Request().Context())
|
||||||
return c.Redirect(http.StatusFound, fmt.Sprintf("/r/%s", v.RoomID))
|
if err != nil {
|
||||||
}
|
c.Logger().Error(err)
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
for _, v := range status {
|
||||||
|
if v.Role == "cohost" {
|
||||||
|
return c.Redirect(http.StatusFound, fmt.Sprintf("/r/%s", v.RoomID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue