Compare commits

..

33 Commits

Author SHA1 Message Date
tuenguyen 96cb549727 Merge pull request 'rebuild' (#8) from fix-modules into master
Reviewed-on: #8
2022-10-11 07:34:13 +00:00
Tue 91086d4f86 rebuild 2022-10-11 14:33:56 +07:00
nguyenphamquangtue 514a7c393c
Merge pull request #7 from Selly-Modules/feature/fix-code
fix code
2022-10-05 17:23:52 +07:00
Tue 290c531c16 fix code 2022-10-05 17:23:29 +07:00
nguyenphamquangtue 193ddba163
Update devicemngt.go 2022-10-05 16:37:16 +07:00
Nam Huynh ad8cc00df6
Merge pull request #6 from Selly-Modules/beta
upgrade mongodb version to 1.0.1
2022-02-24 15:20:58 +07:00
Sinh 30a8570b2e upgrade mongodb version to 1.0.1 2022-02-24 15:12:04 +07:00
Hoang 9435340e44 update DeleteByUserID 2022-02-22 16:36:26 +07:00
Hoang c67099df03 not require UserAgent 2021-12-10 14:58:55 +07:00
Hoang 43fc966f9a update CreateOptions 2021-12-10 11:46:25 +07:00
Hoang 348a8ddb13 add FindAllDevicesByUserIDListAction 2021-12-09 11:35:39 +07:00
Hoang f5ace0d16d update UpdateByDeviceID 2021-11-26 17:37:15 +07:00
Hoang 0feeba0735 add GetUserIDByDeviceId 2021-11-26 17:24:14 +07:00
Hoang 691f9080ab add logger init 2021-11-24 16:26:03 +07:00
Hoang bff00bfa84 add deleteByUserID 2021-11-24 15:36:24 +07:00
Hoang d5d0979321 update delete action 2021-11-23 16:44:42 +07:00
Hoang 1c4cbb1868 update IsDeviceIDExisted 2021-11-23 12:57:22 +07:00
Hoang 2a9870b3d4 update IsDeviceIDExisted 2021-11-22 16:05:28 +07:00
Hoang 59d31f5e63 add IsDeviceIDExistedMethod 2021-11-22 16:02:55 +07:00
Hoang b3a42ef4b2 update deviceModel 2021-11-22 15:14:36 +07:00
Hoang 09cc989cc8 fix modulePath 2021-11-10 17:08:39 +07:00
Hoang 7bea76065a fix comment 2021-11-08 17:23:03 +07:00
Hoang 506a78c566 fix mongoDBConfig 2021-11-08 10:43:09 +07:00
Nam Huynh 61106ecdc1
Merge pull request #5 from Selly-Modules/feature/updateMethod
add update method
2021-11-08 09:56:29 +07:00
Hoang 39d2ca65fc fix comment 2021-11-08 09:46:17 +07:00
Hoang 1f62e375e7 add update method 2021-11-08 08:52:10 +07:00
Nam Huynh 1e95e10fc4
Merge pull request #4 from Selly-Modules/feature/delete-getUserIDByTokenMethod
add delete and getUserIDByToken method
2021-11-07 07:32:18 +07:00
Hoang 1631f921b0 fix comment 2021-11-06 17:35:29 +07:00
Hoang 232349cd44 add delete and getUserIDByToken method 2021-11-05 17:36:30 +07:00
Nam Huynh 385e1f861f
Merge pull request #3 from Selly-Modules/feature/AllMethod
add allMethod
2021-11-05 17:28:54 +07:00
Hoang 7a3fa56b3c fix comment 2021-11-05 17:24:08 +07:00
Hoang 8fcb6cdb08 add allMethod 2021-11-05 16:57:33 +07:00
Nam Huynh dba56c96e3
Merge pull request #2 from Selly-Modules/feature/createMethod
add createMethod
2021-11-05 16:28:05 +07:00
14 changed files with 580 additions and 168 deletions

26
action_check_exists.go Normal file
View File

@ -0,0 +1,26 @@
package devicemngmt
import (
"context"
"git.selly.red/Selly-Modules/logger"
"go.mongodb.org/mongo-driver/bson"
)
func (s Service) IsDeviceIDExisted(deviceID string) bool {
var (
col = s.getDeviceCollection()
ctx = context.Background()
)
total, err := col.CountDocuments(ctx, bson.M{"deviceId": deviceID})
if err != nil {
logger.Error("devicemngmt - isDeviceIDExisted", logger.LogData{
Source: "devicemngmt.IsDeviceIDExisted",
Message: err.Error(),
Data: deviceID,
})
return true
}
return total != 0
}

View File

@ -5,8 +5,8 @@ import (
"errors"
"fmt"
"github.com/Selly-Modules/logger"
"github.com/Selly-Modules/mongodb"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
)
// CreateOptions ...
@ -19,6 +19,11 @@ type CreateOptions struct {
FCMToken string
AuthToken string
Language string
Model string
Manufacturer string
OsName string
OsVersion string
IsMobile bool
}
// Create ...
@ -35,22 +40,20 @@ func (s Service) Create(payload CreateOptions) error {
}
// New device data from payload
deviceData, err := payload.newDevice()
if err != nil {
return err
}
deviceData := payload.newDevice()
// Find deviceID existed or not
if s.isDeviceIDExisted(ctx, deviceData.DeviceID) {
if s.IsDeviceIDExisted(deviceData.DeviceID) {
return errors.New("this device is already existed")
}
// Create device
_, err = col.InsertOne(ctx, deviceData)
if err != nil {
logger.Error("devicemngt - Create ", logger.LogData{
"doc": deviceData,
"err": err.Error(),
logger.Error("devicemngmt - Create ", logger.LogData{
Source: "devicemngmt.Create",
Message: err.Error(),
Data: deviceData,
})
return fmt.Errorf("error when create device: %s", err.Error())
}
@ -58,27 +61,34 @@ func (s Service) Create(payload CreateOptions) error {
return nil
}
func (payload CreateOptions) newDevice() (result Device, err error) {
func (payload CreateOptions) newDevice() Device {
timeNow := now()
device := Device{
// Get userAgent data
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
if osName == "" || osVersion == "" {
osName = payload.OsName
osVersion = payload.OsVersion
isMobile = payload.IsMobile
}
userID, _ := mongodb.NewIDFromString(payload.UserID)
return Device{
ID: mongodb.NewObjectID(),
DeviceID: payload.DeviceID,
OSName: getOSName(payload.UserAgent),
OSVersion: getOSVersion(payload.UserAgent),
OSName: osName,
OSVersion: osVersion,
IP: payload.IP,
Language: getLanguage(payload.Language),
AuthToken: payload.AuthToken,
LastActivatedAt: timeNow,
CreatedAt: timeNow,
FCMToken: payload.FCMToken,
Model: payload.Model,
Manufacturer: payload.Manufacturer,
UserID: userID,
IsMobile: isMobile,
AppVersion: payload.AppVersion,
}
// App version
if payload.AppVersion != "" {
device.AppVersion = payload.AppVersion
device.IsMobile = true
}
result = device
return
}

68
action_delete.go Normal file
View File

@ -0,0 +1,68 @@
package devicemngmt
import (
"context"
"errors"
"fmt"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
"go.mongodb.org/mongo-driver/bson"
)
// DeleteByDeviceID ...
func (s Service) DeleteByDeviceID(deviceID string) error {
var (
ctx = context.Background()
col = s.getDeviceCollection()
cond = bson.M{
"deviceId": deviceID,
}
)
total, _ := col.CountDocuments(ctx, cond)
if total == 0 {
return errors.New("deviceId not found")
}
// Delete
if _, err := col.DeleteOne(ctx, cond); err != nil {
logger.Error("devicemngmt - deleteByDeviceID", logger.LogData{
Source: "devicemngmt.DeleteByDeviceID",
Message: err.Error(),
Data: deviceID,
})
return fmt.Errorf("error when delete device: %s", err.Error())
}
return nil
}
// DeleteByUserID ...
func (s Service) DeleteByUserID(userID string) error {
var (
ctx = context.Background()
col = s.getDeviceCollection()
)
id, isValid := mongodb.NewIDFromString(userID)
if !isValid {
return errors.New("invalid userID data")
}
cond := bson.M{
"userId": id,
}
// Delete
if _, err := col.DeleteMany(ctx, cond); err != nil {
logger.Error("devicemngmt - deleteByUserID", logger.LogData{
Source: "devicemngmt.DeleteByUserID",
Message: err.Error(),
Data: userID,
})
return fmt.Errorf("error when delete device by userId: %s", err.Error())
}
return nil
}

86
action_get_all.go Normal file
View File

@ -0,0 +1,86 @@
package devicemngmt
import (
"context"
"errors"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// FindAllDevicesByUserID ...
func (s Service) FindAllDevicesByUserID(userID string) []Device {
var (
ctx = context.Background()
col = s.getDeviceCollection()
result = make([]Device, 0)
id, _ = mongodb.NewIDFromString(userID)
cond = bson.M{
"userId": id,
}
)
// Find
cursor, err := col.Find(ctx, cond)
if err != nil {
logger.Error("devicemngmt - findAllDevicesByUserID ", logger.LogData{
Source: "devicemngmt.FindAllDevicesByUserID",
Message: err.Error(),
Data: result,
})
return result
}
defer cursor.Close(ctx)
cursor.All(ctx, &result)
return result
}
// FindAllDevicesByUserIDList ...
func (s Service) FindAllDevicesByUserIDList(userIDList []string) (result []Device, err error) {
var (
ctx = context.Background()
col = s.getDeviceCollection()
)
result = make([]Device, 0)
// Validate
if len(userIDList) <= 0 {
err = errors.New("user list must be greater than 0")
}
if len(userIDList) > limit200 {
err = errors.New("user list must be less than 200")
}
// Get ids
ids := make([]primitive.ObjectID, 0)
for _, value := range userIDList {
if id, valid := mongodb.NewIDFromString(value); valid {
ids = append(ids, id)
}
}
// Condition
cond := bson.M{
"userId": bson.M{
"$in": ids,
},
}
// Find
cursor, err := col.Find(ctx, cond)
if err != nil {
logger.Error("devicemngmt - findAllDevicesByUserIDList ", logger.LogData{
Source: "devicemngmt.FindAllDevicesByUserIDList",
Message: err.Error(),
Data: nil,
})
return
}
defer cursor.Close(ctx)
cursor.All(ctx, &result)
return result, nil
}

37
action_get_user_id.go Normal file
View File

@ -0,0 +1,37 @@
package devicemngmt
import (
"context"
"git.selly.red/Selly-Modules/logger"
"go.mongodb.org/mongo-driver/bson"
)
// GetUserIDByAuthToken ...
func (s Service) GetUserIDByAuthToken(authToken string) (userID string) {
var (
ctx = context.Background()
col = s.getDeviceCollection()
device = Device{}
cond = bson.M{
"authToken": authToken,
}
)
if authToken == "" {
return
}
// Find
if err := col.FindOne(ctx, cond).Decode(&device); err != nil {
logger.Error("devicemngmt - getUserIDByAuthToken", logger.LogData{
Source: "devicemngmt.GetUserIDByAuthToken",
Message: err.Error(),
Data: authToken,
})
return
}
userID = device.UserID.Hex()
return
}

89
action_update.go Normal file
View File

@ -0,0 +1,89 @@
package devicemngmt
import (
"context"
"errors"
"fmt"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
"go.mongodb.org/mongo-driver/bson"
)
// UpdateOptions ...
type UpdateOptions struct {
UserID string
UserAgent string
AppVersion string
IP string
FCMToken string
AuthToken string
Language string
Model string
Manufacturer string
OsName string
OsVersion string
IsMobile bool
}
// UpdateByDeviceID ...
func (s Service) UpdateByDeviceID(deviceID string, payload UpdateOptions) error {
var (
ctx = context.Background()
col = s.getDeviceCollection()
cond = bson.M{
"deviceId": deviceID,
}
)
total, _ := col.CountDocuments(ctx, cond)
if total == 0 {
return errors.New("deviceId not found")
}
// Validate payload
err := payload.validate()
if err != nil {
return err
}
// Get userAgent data
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
if osName == "" || osVersion == "" {
osName = payload.OsName
osVersion = payload.OsVersion
isMobile = payload.IsMobile
}
// Setup update data
userID, _ := mongodb.NewIDFromString(payload.UserID)
updateData := bson.M{
"$set": bson.M{
"userId": userID,
"osName": osName,
"osVersion": osVersion,
"ip": payload.IP,
"language": getLanguage(payload.Language),
"authToken": payload.AuthToken,
"fcmToken": payload.FCMToken,
"model": payload.Model,
"manufacturer": payload.Manufacturer,
"appVersion": payload.AppVersion,
"isMobile": isMobile,
"lastActivatedAt": now(),
},
}
// Update
_, err = col.UpdateOne(ctx, cond, updateData)
if err != nil {
logger.Error("devicemngmt - updateByDeviceID", logger.LogData{
Source: "devicemngmt.UpdateByDeviceID",
Message: err.Error(),
Data: deviceID,
})
return fmt.Errorf("error when update device: %s", err.Error())
}
return nil
}

View File

@ -3,9 +3,12 @@ package devicemngmt
// Constant ...
const (
tableDevice = "devices"
tablePrefixDefault = "devicemngmt"
timezoneHCM = "Asia/Ho_Chi_Minh"
langVi = "vi"
langEn = "en"
limit200 = 200
)

15
db.go Normal file
View File

@ -0,0 +1,15 @@
package devicemngmt
import (
"fmt"
"go.mongodb.org/mongo-driver/mongo"
)
// getDeviceCollection ...
func (s Service) getDeviceCollection() *mongo.Collection {
if s.TablePrefix != "" {
return s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableDevice))
}
return s.DB.Collection(tableDevice)
}

View File

@ -4,19 +4,15 @@ import (
"errors"
"fmt"
"github.com/Selly-Modules/mongodb"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
"go.mongodb.org/mongo-driver/mongo"
)
// MongoDBConfig ...
type MongoDBConfig struct {
Host, User, Password, DBName, mechanism, source string
}
// Config ...
type Config struct {
// MongoDB config, for save documents
MongoDB MongoDBConfig
MongoDB mongodb.Config
// Table prefix, each service has its own prefix
TablePrefix string
}
@ -31,24 +27,24 @@ var s *Service
// Init ...
func Init(config Config) (*Service, error) {
if config.MongoDB.Host == "" || config.TablePrefix == "" {
if config.MongoDB.Host == "" {
return nil, errors.New("please provide all necessary information for init device")
}
// If prefixTable is empty then it is devicemngmt
if config.TablePrefix == "" {
config.TablePrefix = tablePrefixDefault
}
// Connect MongoDB
db, err := mongodb.Connect(
config.MongoDB.Host,
config.MongoDB.User,
config.MongoDB.Password,
config.MongoDB.DBName,
config.MongoDB.mechanism,
config.MongoDB.source,
)
db, err := mongodb.Connect(config.MongoDB)
if err != nil {
fmt.Println("Cannot init module DEVICE MANAGEMENT", err)
return nil, err
}
logger.Init(fmt.Sprintf("%s-devicemngmt", config.TablePrefix), "")
s = &Service{
Config: config,
DB: db,
@ -61,3 +57,13 @@ func Init(config Config) (*Service, error) {
func GetInstance() *Service {
return s
}
// GetConnectOptions ...
func GetConnectOptions(Host, DBName string) mongodb.Config {
return mongodb.Config{
Host: Host,
DBName: DBName,
Standalone: &mongodb.ConnectStandaloneOpts{},
TLS: &mongodb.ConnectTLSOpts{},
}
}

56
go.mod
View File

@ -1,46 +1,44 @@
module github.com/selly-Modules/devicemngmt
module git.selly.red/Selly-Modules/devicemngmt
go 1.17
require (
github.com/Selly-Modules/logger v0.0.0-20210809034923-140a51f39ec9
github.com/Selly-Modules/mongodb v0.0.0-20211013094205-a8ab24a96c4c
github.com/dgrijalva/jwt-go v3.2.0+incompatible
git.selly.red/Selly-Modules/logger v0.0.3-0.20221010034051-82b204026f8c
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2
github.com/mssola/user_agent v0.5.3
go.mongodb.org/mongo-driver v1.7.4
go.mongodb.org/mongo-driver v1.10.3
)
require (
github.com/armon/go-radix v1.0.0 // indirect
github.com/elastic/go-licenser v0.3.1 // indirect
github.com/elastic/go-sysinfo v1.1.1 // indirect
github.com/elastic/go-windows v1.0.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/jcchavezs/porto v0.1.0 // indirect
github.com/elastic/go-licenser v0.4.1 // indirect
github.com/elastic/go-sysinfo v1.8.1 // indirect
github.com/elastic/go-windows v1.0.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/jcchavezs/porto v0.4.0 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.elastic.co/apm v1.13.1 // indirect
go.elastic.co/apm/module/apmzap v1.13.1 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.elastic.co/apm v1.15.0 // indirect
go.elastic.co/apm/module/apmzap v1.15.0 // indirect
go.elastic.co/fastjson v1.1.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 // indirect
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
golang.org/x/tools v0.1.12 // indirect
howett.net/plist v1.0.0 // indirect
)

139
go.sum
View File

@ -1,22 +1,24 @@
git.selly.red/Selly-Modules/logger v0.0.3-0.20221010034051-82b204026f8c h1:eqGjWFibI3/7ovg9fGBx//E/I2HyydnkstphghcLiQI=
git.selly.red/Selly-Modules/logger v0.0.3-0.20221010034051-82b204026f8c/go.mod h1:q1q2tXmja+vOKo3IU7qZhRXaEBB5jETxHqUlYHsAUEQ=
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2 h1:bePzcMN/j4V1fvz6UUrN01ey1tkE0w+m5Qj3LtoZs4E=
git.selly.red/Selly-Modules/mongodb v1.0.6-0.20221010033754-1d897a0f9ea2/go.mod h1:Xvs3E6YbTPI5I4+I1aXrY0A79XaCfw+0tqV8dihvheE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Selly-Modules/logger v0.0.0-20210809034923-140a51f39ec9 h1:AuJ/IIZ7yppyP19ILEYkwz26CwGXR4xUyXANKSG0+1U=
github.com/Selly-Modules/logger v0.0.0-20210809034923-140a51f39ec9/go.mod h1:RWhSQ3F01an8KD00VjzRBZOMcE5eV2Cy0/l4ZkeieyU=
github.com/Selly-Modules/mongodb v0.0.0-20211013094205-a8ab24a96c4c h1:1l6QmAl43maG9zFyUXrPQVUjyVt0vy/2Saz992UR+Sc=
github.com/Selly-Modules/mongodb v0.0.0-20211013094205-a8ab24a96c4c/go.mod h1:C9O0Bgl9i6szjntMjBdEvaFSqG2UPOgHUspIWIJ93JQ=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/elastic/go-licenser v0.3.1 h1:RmRukU/JUmts+rpexAw0Fvt2ly7VVu6mw8z4HrEzObU=
github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ=
github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI=
github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4=
github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY=
github.com/elastic/go-sysinfo v1.8.1 h1:4Yhj+HdV6WjbCRgGdZpPJ8lZQlXZLKDAeIkmQ/VRvi4=
github.com/elastic/go-sysinfo v1.8.1/go.mod h1:JfllUnzoQV/JRYymbH3dO1yggI3mV2oTKSXsDHM+uIM=
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
@ -42,13 +44,17 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jcchavezs/porto v0.1.0 h1:Xmxxn25zQMmgE7/yHYmh19KcItG81hIwfbEEFnd6w/Q=
github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A=
github.com/jcchavezs/porto v0.4.0 h1:Zj7RligrxmDdKGo6fBO2xYAHxEgrVBfs1YAja20WbV4=
github.com/jcchavezs/porto v0.4.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4=
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak=
@ -56,8 +62,9 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -68,6 +75,8 @@ github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/z
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ=
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/mssola/user_agent v0.5.3 h1:lBRPML9mdFuIZgI2cmlQ+atbpJdLdeVl2IDodjBR578=
github.com/mssola/user_agent v0.5.3/go.mod h1:TTPno8LPY3wAIEKRpAtkdMT0f8SE24pLRGPahjCH4uw=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
@ -75,9 +84,11 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 h1:c8R11WC8m7KNMkTv/0+Be8vvwo4I3/Ut9AC2FW8fX3U=
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@ -90,63 +101,93 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc=
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.elastic.co/apm v1.13.1 h1:ICIcUcQOImg/bve9mQVyLCvm1cSUZ1afdwK6ACnxczU=
go.elastic.co/apm v1.13.1/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY=
go.elastic.co/apm/module/apmzap v1.13.1 h1:Soa4vNYYabPvOW1vm1A00C0UcEmfEzcx3YBjAgf5ue4=
go.elastic.co/apm/module/apmzap v1.13.1/go.mod h1:Tu8/TwffpBoNGmI05VcL1Ye2AC8oXrlMKNaKD1TIQy0=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.elastic.co/apm v1.15.0 h1:uPk2g/whK7c7XiZyz/YCUnAUBNPiyNeE3ARX3G6Gx7Q=
go.elastic.co/apm v1.15.0/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY=
go.elastic.co/apm/module/apmzap v1.15.0 h1:SjXslnImV3jaK2BtNqRl994H9mpG8+6qqPAahbzwIys=
go.elastic.co/apm/module/apmzap v1.15.0/go.mod h1:eowOIqa+vS+BZ9YOCztd8poYGxSxXh8YfVuOHTMhKQs=
go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4=
go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI=
go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8=
go.mongodb.org/mongo-driver v1.7.4 h1:sllcioag8Mec0LYkftYWq+cKNPIR4Kqq3iv9ZXY0g/E=
go.mongodb.org/mongo-driver v1.7.4/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg=
go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA=
go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U=
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI=
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 h1:cu5kTvlzcw1Q5S9f5ip1/cpiB4nXvw1XYzFPGgzLUOY=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -154,11 +195,27 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211102192858-4dd72447c267/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -167,22 +224,28 @@ golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 h1:MeC2gMlMdkd67dn17MEby3rGXRxZtWeiRXOnISfTQ74=
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=

View File

@ -1,44 +1,12 @@
package devicemngmt
import (
"context"
"fmt"
"github.com/Selly-Modules/logger"
ua "github.com/mssola/user_agent"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
// getDeviceCollection ...
func (s Service) getDeviceCollection() *mongo.Collection {
return s.DB.Collection(fmt.Sprintf("%s-%s", s.TablePrefix, tableDevice))
}
func (s Service) isDeviceIDExisted(ctx context.Context, deviceID string) bool {
var (
col = s.getDeviceCollection()
device = Device{}
)
if err := col.FindOne(ctx, bson.M{"deviceID": deviceID}).Decode(&device); err != nil {
logger.Error("devicemngt - findByDeviceID", logger.LogData{
"deviceID": deviceID,
"err": err.Error(),
})
return true
}
return !device.ID.IsZero()
}
func getOSName(userAgent string) string {
func getUserAgentData(userAgent string) (string, string, bool) {
uaData := ua.New(userAgent)
return uaData.OSInfo().Name
}
func getOSVersion(userAgent string) string {
uaData := ua.New(userAgent)
return uaData.OSInfo().Version
return uaData.OSInfo().Name, uaData.OSInfo().Version, uaData.Mobile()
}
func getLanguage(lang string) string {

View File

@ -9,7 +9,7 @@ import (
// Device ...
type Device struct {
ID primitive.ObjectID `bson:"_id" json:"_id"`
DeviceID string `bson:"deviceID" json:"deviceId"` // unique
DeviceID string `bson:"deviceId" json:"deviceId"` // unique
IP string `bson:"ip" json:"ip"`
OSName string `bson:"osName" json:"osName"`
OSVersion string `bson:"osVersion" json:"osVersion"`
@ -17,8 +17,10 @@ type Device struct {
Language string `bson:"language" json:"language"` // vi, en
IsMobile bool `bson:"isMobile" json:"isMobile"`
LastActivatedAt time.Time `bson:"lastActivatedAt" json:"lastActivatedAt"`
UserID primitive.ObjectID `bson:"userID" json:"userId"`
UserID primitive.ObjectID `bson:"userId" json:"userId"`
AuthToken string `bson:"authToken" json:"authToken"`
FCMToken string `bson:"fcmToken" json:"fcmToken"`
Model string `bson:"model" json:"model"`
Manufacturer string `bson:"manufacturer" json:"manufacturer"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
}

View File

@ -3,46 +3,87 @@ package devicemngmt
import (
"errors"
"github.com/Selly-Modules/logger"
"git.selly.red/Selly-Modules/logger"
"git.selly.red/Selly-Modules/mongodb"
)
func (co CreateOptions) validate() error{
func (co CreateOptions) validate() error {
// DeviceID
if co.DeviceID == "" {
logger.Error("devicemngt - Create: no deviceID data", logger.LogData{
"payload": co,
logger.Error("devicemngmt - Create: no deviceID data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Create: no deviceID data",
Data: co,
})
return errors.New("no deviceID data")
}
// UserAgent
if co.UserAgent == "" {
logger.Error("devicemngt - Create: no userAgent data", logger.LogData{
"payload": co,
})
return errors.New("no userAgent data")
}
// IP
if co.IP == "" {
logger.Error("devicemngt - Create: no ip data", logger.LogData{
"payload": co,
logger.Error("devicemngmt - Create: no ip data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Create: no ip data",
Data: co,
})
return errors.New("no ip data")
}
// UserID
if co.UserID == "" {
logger.Error("devicemngt - Create: no userID data", logger.LogData{
"payload": co,
logger.Error("devicemngmt - Create: no userID data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Create: no userID data",
Data: co,
})
return errors.New("no userID data")
}
if _, isValid := mongodb.NewIDFromString(co.UserID); !isValid {
return errors.New("invalid userID data")
}
// AuthToken
if co.AuthToken == "" {
logger.Error("devicemngt - Create: no authToken data", logger.LogData{
"payload": co,
logger.Error("devicemngmt - Create: no authToken data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Create: no authToken data",
Data: co,
})
return errors.New("no authToken data")
}
return nil
}
func (uo UpdateOptions) validate() error {
// UserID
if uo.UserID == "" {
logger.Error("devicemngmt - Update: no userID data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Update: no userID data",
Data: uo,
})
return errors.New("no userID data")
}
if _, isValid := mongodb.NewIDFromString(uo.UserID); !isValid {
return errors.New("invalid userID data")
}
// IP
if uo.IP == "" {
logger.Error("devicemngmt - Update: no ip data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Update: no ip data",
Data: uo,
})
return errors.New("no ip data")
}
// AuthToken
if uo.AuthToken == "" {
logger.Error("devicemngmt - Update: no authToken data", logger.LogData{
Source: "devicemngmt.validate",
Message: "devicemngmt - Update: no authToken data",
Data: uo,
})
return errors.New("no authToken data")
}