fix comment again
This commit is contained in:
		
							parent
							
								
									9905ab89ae
								
							
						
					
					
						commit
						85c9692da0
					
				| 
						 | 
					@ -61,16 +61,16 @@ func (s Service) Create(payload CreateOptions) error {
 | 
				
			||||||
func (payload CreateOptions) newDevice() (result Device, err error) {
 | 
					func (payload CreateOptions) newDevice() (result Device, err error) {
 | 
				
			||||||
	timeNow := now()
 | 
						timeNow := now()
 | 
				
			||||||
	device := Device{
 | 
						device := Device{
 | 
				
			||||||
		ID:             mongodb.NewObjectID(),
 | 
							ID:              mongodb.NewObjectID(),
 | 
				
			||||||
		DeviceID:       payload.DeviceID,
 | 
							DeviceID:        payload.DeviceID,
 | 
				
			||||||
		OSName:         getOSName(payload.UserAgent),
 | 
							OSName:          getOSName(payload.UserAgent),
 | 
				
			||||||
		OSVersion:      getOSVersion(payload.UserAgent),
 | 
							OSVersion:       getOSVersion(payload.UserAgent),
 | 
				
			||||||
		IP:             payload.IP,
 | 
							IP:              payload.IP,
 | 
				
			||||||
		Language:       getLanguage(payload.Language),
 | 
							Language:        getLanguage(payload.Language),
 | 
				
			||||||
		AuthToken:      payload.AuthToken,
 | 
							AuthToken:       payload.AuthToken,
 | 
				
			||||||
		LastActivityAt: timeNow,
 | 
							LastActivatedAt: timeNow,
 | 
				
			||||||
		CreatedAt:      timeNow,
 | 
							CreatedAt:       timeNow,
 | 
				
			||||||
		FCMToken:       payload.FCMToken,
 | 
							FCMToken:        payload.FCMToken,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// App version
 | 
						// App version
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,12 +26,9 @@ func (s Service) isDeviceIDExisted(ctx context.Context, deviceID string) bool {
 | 
				
			||||||
			"deviceID": deviceID,
 | 
								"deviceID": deviceID,
 | 
				
			||||||
			"err":      err.Error(),
 | 
								"err":      err.Error(),
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if !device.ID.IsZero() {
 | 
					 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return !device.ID.IsZero()
 | 
				
			||||||
	return false
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func getOSName(userAgent string) string {
 | 
					func getOSName(userAgent string) string {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								model.go
								
								
								
								
							
							
						
						
									
										26
									
								
								model.go
								
								
								
								
							| 
						 | 
					@ -8,17 +8,17 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Device ...
 | 
					// Device ...
 | 
				
			||||||
type Device struct {
 | 
					type Device struct {
 | 
				
			||||||
	ID             primitive.ObjectID `bson:"_id" json:"_id"`
 | 
						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"`
 | 
						IP              string             `bson:"ip" json:"ip"`
 | 
				
			||||||
	OSName         string             `bson:"osName" json:"osName"`
 | 
						OSName          string             `bson:"osName" json:"osName"`
 | 
				
			||||||
	OSVersion      string             `bson:"osVersion" json:"osVersion"`
 | 
						OSVersion       string             `bson:"osVersion" json:"osVersion"`
 | 
				
			||||||
	AppVersion     string             `bson:"appVersion" json:"appVersion"`
 | 
						AppVersion      string             `bson:"appVersion" json:"appVersion"`
 | 
				
			||||||
	Language       string             `bson:"language" json:"language"` // vi, en
 | 
						Language        string             `bson:"language" json:"language"` // vi, en
 | 
				
			||||||
	IsMobile       bool               `bson:"isMobile" json:"isMobile"`
 | 
						IsMobile        bool               `bson:"isMobile" json:"isMobile"`
 | 
				
			||||||
	LastActivityAt time.Time          `bson:"lastActivityAt" json:"lastActivityAt"`
 | 
						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"`
 | 
						AuthToken       string             `bson:"authToken" json:"authToken"`
 | 
				
			||||||
	FCMToken       string             `bson:"fcmToken" json:"fcmToken"`
 | 
						FCMToken        string             `bson:"fcmToken" json:"fcmToken"`
 | 
				
			||||||
	CreatedAt      time.Time          `bson:"createdAt" json:"createdAt"`
 | 
						CreatedAt       time.Time          `bson:"createdAt" json:"createdAt"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue