-
Notifications
You must be signed in to change notification settings - Fork 357
/
status.setSessionOnline_handler.go
46 lines (38 loc) · 1.23 KB
/
status.setSessionOnline_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Created from 'scheme.tl' by 'mtprotoc'
*
* Copyright (c) 2021-present, Teamgram Studio (https://teamgram.io).
* All rights reserved.
*
* Author: teamgramio (teamgram.io@gmail.com)
*/
package core
import (
"strconv"
"github.com/teamgram/proto/mtproto"
"github.com/teamgram/teamgram-server/app/service/status/status"
)
// StatusSetSessionOnline
// status.setSessionOnline online:SessionEntry = Bool;
func (c *StatusCore) StatusSetSessionOnline(in *status.TLStatusSetSessionOnline) (*mtproto.Bool, error) {
var (
userK = getUserKey(in.GetUserId())
authK = getAuthKeyIdKey(in.GetAuthKeyId())
)
if err := c.svcCtx.KV.Hset(
userK,
strconv.FormatInt(in.GetAuthKeyId(), 10),
in.GetGateway()); err != nil {
c.Logger.Errorf("status.setSessionOnline(%s) error(%v)", in.DebugString(), err)
return nil, err
}
if err := c.svcCtx.KV.Expire(userK, c.svcCtx.Config.StatusExpire); err != nil {
c.Logger.Errorf("status.setSessionOnline(%s) error(%v)", in.DebugString(), err)
return nil, err
}
if err := c.svcCtx.KV.Setex(authK, in.GetGateway(), c.svcCtx.Config.StatusExpire); err != nil {
c.Logger.Errorf("status.setSessionOnline(%s) error(%v)", in.DebugString(), err)
return nil, err
}
return mtproto.BoolTrue, nil
}