Skip to content

Commit 5b93bc6

Browse files
committed
修改UserSig返回
1 parent 7714330 commit 5b93bc6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

im.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
package im
99

1010
import (
11+
"time"
12+
1113
"github.com/dobyte/tencent-im/account"
1214
"github.com/dobyte/tencent-im/group"
1315
"github.com/dobyte/tencent-im/internal/core"
@@ -25,7 +27,7 @@ type Error = core.Error
2527
type (
2628
IM interface {
2729
// GetUserSig 获取UserSig签名
28-
GetUserSig() string
30+
GetUserSig() UserSig
2931
// SNS 获取关系链管理接口
3032
SNS() sns.API
3133
// Mute 获取全局禁言管理接口
@@ -51,6 +53,11 @@ type (
5153
Expire int // UserSig过期时间
5254
}
5355

56+
UserSig struct {
57+
UserSig string // 用户签名
58+
ExpireAt int64 // 签名过期时间
59+
}
60+
5461
im struct {
5562
opt Options
5663
client core.Client
@@ -67,9 +74,10 @@ func NewIM(opt Options) IM {
6774
}
6875

6976
// GetUserSig 获取UserSig签名
70-
func (i *im) GetUserSig() string {
77+
func (i *im) GetUserSig() UserSig {
7178
userSig, _ := sign.GenUserSig(i.opt.AppId, i.opt.AppSecret, i.opt.UserId, i.opt.Expire)
72-
return userSig
79+
expireAt := time.Now().Add(time.Duration(i.opt.Expire) * time.Second).Unix()
80+
return UserSig{UserSig: userSig, ExpireAt: expireAt}
7381
}
7482

7583
// SNS 获取关系链管理接口

0 commit comments

Comments
 (0)