Skip to content

Commit

Permalink
更新UserSig
Browse files Browse the repository at this point in the history
  • Loading branch information
dobyte committed Oct 16, 2021
1 parent 2bba99c commit 7714330
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 274 deletions.
118 changes: 62 additions & 56 deletions im.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,108 @@
package im

import (
"github.com/dobyte/tencent-im/account"
"github.com/dobyte/tencent-im/group"
"github.com/dobyte/tencent-im/internal/core"
"github.com/dobyte/tencent-im/mute"
"github.com/dobyte/tencent-im/operation"
"github.com/dobyte/tencent-im/private"
"github.com/dobyte/tencent-im/profile"
"github.com/dobyte/tencent-im/push"
"github.com/dobyte/tencent-im/sns"
"github.com/dobyte/tencent-im/account"
"github.com/dobyte/tencent-im/group"
"github.com/dobyte/tencent-im/internal/core"
"github.com/dobyte/tencent-im/internal/sign"
"github.com/dobyte/tencent-im/mute"
"github.com/dobyte/tencent-im/operation"
"github.com/dobyte/tencent-im/private"
"github.com/dobyte/tencent-im/profile"
"github.com/dobyte/tencent-im/push"
"github.com/dobyte/tencent-im/sns"
)

type Error = core.Error

type (
IM interface {
// SNS 获取关系链管理接口
SNS() sns.API
// Mute 获取全局禁言管理接口
Mute() mute.API
// Push 获取全员推送接口
Push() push.API
// Group 获取群组管理接口
Group() group.API
// Account 获取账号管理接口
Account() account.API
// Profile 获取资料管理接口
Profile() profile.API
// Private 获取私聊消息接口
Private() private.API
// Operation 获取运营管理接口
Operation() operation.API
}

Options struct {
AppId int // 应用 SDKAppID,可在即时通信 IM 控制台 的应用卡片中获取。
AppSecret string // 密钥信息,可在即时通信 IM 控制台 的应用详情页面中获取,具体操作请参见 获取密钥
UserId string // 用户ID
}

im struct {
client core.Client
appId int
appSecret string
}
IM interface {
// GetUserSig 获取UserSig签名
GetUserSig() string
// SNS 获取关系链管理接口
SNS() sns.API
// Mute 获取全局禁言管理接口
Mute() mute.API
// Push 获取全员推送接口
Push() push.API
// Group 获取群组管理接口
Group() group.API
// Account 获取账号管理接口
Account() account.API
// Profile 获取资料管理接口
Profile() profile.API
// Private 获取私聊消息接口
Private() private.API
// Operation 获取运营管理接口
Operation() operation.API
}

Options struct {
AppId int // 应用SDKAppID,可在即时通信 IM 控制台 的应用卡片中获取。
AppSecret string // 密钥信息,可在即时通信 IM 控制台 的应用详情页面中获取,具体操作请参见 获取密钥
UserId string // 用户ID
Expire int // UserSig过期时间
}

im struct {
opt Options
client core.Client
}
)

// NewIM create a im instance.
func NewIM(opt Options) IM {
return &im{
appId: opt.AppId,
client: core.NewClient(core.Options{
AppId: opt.AppId,
AppSecret: opt.AppSecret,
UserId: opt.UserId,
}),
}
return &im{opt: opt, client: core.NewClient(core.Options{
AppId: opt.AppId,
AppSecret: opt.AppSecret,
UserId: opt.UserId,
Expire: opt.Expire,
})}
}

// GetUserSig 获取UserSig签名
func (i *im) GetUserSig() string {
userSig, _ := sign.GenUserSig(i.opt.AppId, i.opt.AppSecret, i.opt.UserId, i.opt.Expire)
return userSig
}

// SNS 获取关系链管理接口
func (i *im) SNS() sns.API {
return sns.NewAPI(i.client)
return sns.NewAPI(i.client)
}

// Mute 获取全局禁言管理接口
func (i *im) Mute() mute.API {
return mute.NewAPI(i.client)
return mute.NewAPI(i.client)
}

// Push 获取全员推送接口
func (i *im) Push() push.API {
return push.NewAPI(i.client)
return push.NewAPI(i.client)
}

// Group 获取群组管理接口
func (i *im) Group() group.API {
return group.NewAPI(i.client)
return group.NewAPI(i.client)
}

// Account 获取账号管理接口
func (i *im) Account() account.API {
return account.NewAPI(i.client)
return account.NewAPI(i.client)
}

// Profile 获取资料管理接口
func (i *im) Profile() profile.API {
return profile.NewAPI(i.client)
return profile.NewAPI(i.client)
}

// Private 获取私聊消息接口
func (i *im) Private() private.API {
return private.NewAPI(i.client)
return private.NewAPI(i.client)
}

// Operation 获取运营管理接口
func (i *im) Operation() operation.API {
return operation.NewAPI(i.client)
return operation.NewAPI(i.client)
}

func (i *im) Callback() {
Expand Down
Loading

0 comments on commit 7714330

Please sign in to comment.