1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-02-09 13:13:44 +02:00

build-passing commit

This commit is contained in:
gtourkas 2021-04-15 12:12:28 +03:00
parent 2b791ae0ba
commit da3ffb0a7d
2 changed files with 37 additions and 35 deletions

View File

@ -33,11 +33,11 @@ You also need a user subscribed to your Official Account. You can use your own:
## Usage
```go
package main
import (
"github.com/silenceper/wechat/v2/cache"
"log"
"context"
"fmt"
@ -48,11 +48,12 @@ import (
func main() {
wechatSvc := wechat.New(wechat.Config{
wechatSvc := wechat.New(&wechat.Config{
AppID: "abcdefghi",
AppSecret: "jklmnopqr",
Token: "mytoken",
EncodingAESKey: "IGNORED-IN-SANDBOX",
Cache: cache.NewMemory(),
})
// do this only once, or when settings are updated

View File

@ -20,6 +20,7 @@ type Config struct {
AppSecret string
Token string
EncodingAESKey string
Cache cache.Cache
}
// wechatMessageManager abstracts go-wechat's message.Manager for writing unit tests
@ -29,15 +30,15 @@ type wechatMessageManager interface {
// Service encapsulates the WeChat client along with internal state for storing users.
type Service struct {
config Config
config *Config
messageManager wechatMessageManager
userIDs []string
}
// New returns a new instance of a WeChat notification service.
func New(cfg Config) *Service {
client := wechat.NewWechat()
clientConfig := &config.Config{
func New(cfg *Config) *Service {
wc := wechat.NewWechat()
wcCfg := &config.Config{
AppID: cfg.AppID,
AppSecret: cfg.AppSecret,
Token: cfg.Token,
@ -45,7 +46,7 @@ func New(cfg Config) *Service {
Cache: cfg.Cache,
}
account := wc.GetOfficialAccount(wcCfg)
oa := wc.GetOfficialAccount(wcCfg)
return &Service{
config: cfg,