-
Notifications
You must be signed in to change notification settings - Fork 1
/
account.setAccountTTL_handler.go
executable file
·36 lines (31 loc) · 1.15 KB
/
account.setAccountTTL_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
/*
* Copyright (c) 2018, https://github.com/airwide-code/airwide.datacenter
* All rights reserved.
*
*
*
*/
package rpc
import (
"github.com/golang/glog"
"github.com/airwide-code/airwide.datacenter/baselib/logger"
"github.com/airwide-code/airwide.datacenter/baselib/grpc_util"
"github.com/airwide-code/airwide.datacenter/mtproto"
"golang.org/x/net/context"
"github.com/airwide-code/airwide.datacenter/biz/core/account"
)
// account.setAccountTTL#2442485e ttl:AccountDaysTTL = Bool;
func (s *AccountServiceImpl) AccountSetAccountTTL(ctx context.Context, request *mtproto.TLAccountSetAccountTTL) (*mtproto.Bool, error) {
md := grpc_util.RpcMetadataFromIncoming(ctx)
glog.Infof("AccountSetAccountTTL - metadata: %s, request: %s", logger.JsonDebugData(md), logger.JsonDebugData(request))
// TODO(@benqi): Check ttl
ttl := request.GetTtl().GetData2().GetDays()
if ttl <= 0 || ttl > 365 {
err := mtproto.NewRpcError2(mtproto.TLRpcErrorCodes_BAD_REQUEST)
glog.Error("ttl_days error: ", err)
return nil, err
}
account.SetAccountDaysTTL(md.UserId, ttl)
glog.Infof("account.setAccountTTL#2442485e - reply: {true}")
return mtproto.ToBool(true), nil
}