@@ -765,14 +765,14 @@ func (rc *RedisCache) GetRoomUnreadCount(userID, roomID string) (int64, int64, e
765
765
func (rc * RedisCache ) GetPresences (userID string ) (* authtypes.Presences , bool ) {
766
766
key := fmt .Sprintf ("%s:%s" , "presences" , userID )
767
767
768
- reply , err := redis .Values (rc .SafeDo ("hmget" , key , "user_id" , "status" , "status_msg" , "ext_status_msg" ))
768
+ reply , err := redis .Values (rc .SafeDo ("hmget" , key , "user_id" , "status" , "status_msg" , "ext_status_msg" , "server_status" ))
769
769
if err != nil {
770
770
log .Errorw ("cache missed for presences" , log.KeysAndValues {"userID" , userID , "error" , err })
771
771
return nil , false
772
772
} else {
773
773
var presences authtypes.Presences
774
774
775
- reply , err = redis .Scan (reply , & presences .UserID , & presences .Status , & presences .StatusMsg , & presences .ExtStatusMsg )
775
+ reply , err = redis .Scan (reply , & presences .UserID , & presences .Status , & presences .StatusMsg , & presences .ExtStatusMsg , & presences . ServerStatus )
776
776
if err != nil {
777
777
log .Errorw ("Scan error for presences" , log.KeysAndValues {"userID" , userID , "error" , err })
778
778
return nil , false
@@ -794,6 +794,17 @@ func (rc *RedisCache) SetPresences(userID, status, statusMsg, extStatusMsg strin
794
794
return conn .Flush ()
795
795
}
796
796
797
+ func (rc * RedisCache ) SetPresencesServerStatus (userID , serverStatus string ) error {
798
+ conn := rc .pool ().Get ()
799
+ defer conn .Close ()
800
+ key := fmt .Sprintf ("%s:%s" , "presences" , userID )
801
+ err := conn .Send ("hmset" , key , "server_status" , serverStatus )
802
+ if err != nil {
803
+ return err
804
+ }
805
+ return conn .Flush ()
806
+ }
807
+
797
808
func (rc * RedisCache ) SetAccountData (userID , roomID , acctType , content string ) error {
798
809
conn := rc .pool ().Get ()
799
810
defer conn .Close ()
@@ -998,24 +1009,24 @@ func (rc *RedisCache) GetDomains() ([]string, error) {
998
1009
}
999
1010
1000
1011
func (rc * RedisCache ) GetUserInfoByUserID (userID string ) (result * authtypes.UserInfo ) {
1001
- reply , err := redis .Values (rc .SafeDo ("hmget" , fmt .Sprintf ("%s:%s" , "user_info" , userID ), "user_id" , "user_name" , "job_number" , "mobile" , "landline" , "email" ))
1012
+ reply , err := redis .Values (rc .SafeDo ("hmget" , fmt .Sprintf ("%s:%s" , "user_info" , userID ), "user_id" , "user_name" , "job_number" , "mobile" , "landline" , "email" , "state" ))
1002
1013
if err != nil {
1003
1014
log .Errorw ("cache missed for user_info" , log.KeysAndValues {"userID" , userID , "error" , err })
1004
1015
} else {
1005
1016
result = & authtypes.UserInfo {}
1006
- reply , err = redis .Scan (reply , & result .UserID , & result .UserName , & result .JobNumber , & result .Mobile , & result .Landline , & result .Email )
1017
+ reply , err = redis .Scan (reply , & result .UserID , & result .UserName , & result .JobNumber , & result .Mobile , & result .Landline , & result .Email , & result . State )
1007
1018
if err != nil {
1008
1019
log .Errorw ("Scan error for user_info" , log.KeysAndValues {"userID" , userID , "error" , err })
1009
1020
}
1010
1021
}
1011
1022
return
1012
1023
}
1013
1024
1014
- func (rc * RedisCache ) SetUserInfo (userID , userName , jobNumber , mobile , landline , email string ) error {
1025
+ func (rc * RedisCache ) SetUserInfo (userID , userName , jobNumber , mobile , landline , email string , state int ) error {
1015
1026
conn := rc .pool ().Get ()
1016
1027
defer conn .Close ()
1017
1028
1018
- err := conn .Send ("hmset" , fmt .Sprintf ("%s:%s" , "user_info" , userID ), "user_id" , userID , "user_name" , userName , "job_number" , jobNumber , "mobile" , mobile , "landline" , landline , "email" , email )
1029
+ err := conn .Send ("hmset" , fmt .Sprintf ("%s:%s" , "user_info" , userID ), "user_id" , userID , "user_name" , userName , "job_number" , jobNumber , "mobile" , mobile , "landline" , landline , "email" , email , "state" , state )
1019
1030
if err != nil {
1020
1031
return err
1021
1032
}
@@ -1375,3 +1386,23 @@ func (rc *RedisCache) FreeFedBackfill(roomID string) error {
1375
1386
err := conn .Send ("DEL" , "fedbackfill:" + roomID )
1376
1387
return err
1377
1388
}
1389
+
1390
+ func (rc * RedisCache ) SetRoomLatestOffset (roomId string , offset int64 ) error {
1391
+ conn := rc .pool ().Get ()
1392
+ defer conn .Close ()
1393
+ key := fmt .Sprintf ("%s:%s" , "roomlatestoffset" , roomId )
1394
+ err := conn .Send ("set" , key , offset )
1395
+ if err != nil {
1396
+ return err
1397
+ }
1398
+ return conn .Flush ()
1399
+ }
1400
+
1401
+ func (rc * RedisCache ) GetRoomLatestOffset (roomId string ) (int64 , error ) {
1402
+ key := fmt .Sprintf ("%s:%s" , "roomlatestoffset" , roomId )
1403
+ offset , err := redis .Int64 (rc .SafeDo ("get" , key ))
1404
+ if err != nil {
1405
+ return - 1 , err
1406
+ }
1407
+ return offset , err
1408
+ }
0 commit comments