Feat: join team
This commit is contained in:
@ -60,6 +60,26 @@ func getStateByCtx(ctx context.Context) (*models.UserState, error) {
|
||||
return us, nil
|
||||
}
|
||||
|
||||
func saveStateByCtx(ctx context.Context, state *models.UserState) error {
|
||||
username, ok := ctx.Value(models.CtxUsernameKey).(string)
|
||||
if !ok {
|
||||
log.Debug("no username in ctx")
|
||||
return errors.New("no username in ctx")
|
||||
}
|
||||
return saveState(username, state)
|
||||
}
|
||||
|
||||
func saveFullInfoByUsername(username string, fi *models.FullInfo) error {
|
||||
// INFO: unfortunately working no transactions; so case are possible where first object is updated but the second is not
|
||||
if err := saveState(username, fi.State); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := saveRoom(fi.Room); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// cache
|
||||
|
||||
func saveState(username string, state *models.UserState) error {
|
||||
|
Reference in New Issue
Block a user