Skip to content

Commit aa41047

Browse files
committed
fix: field tags
1 parent 3d8a1e1 commit aa41047

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

botsfwmodels/base_data.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,33 @@ import (
88
// BotBaseData holds properties common to all bot entities
99
type BotBaseData struct {
1010
//user.OwnedByUserWithID
11-
AppUserID string // intentionally indexed & do NOT omitempty (so we can find records with empty AppUserID)
11+
AppUserID string `json:"appUserID" dalgo:"appUserID" firestore:"appUserID"` // intentionally indexed & do NOT omitempty (so we can find records with empty AppUserID)
1212

1313
// AppUserIntID is a strongly typed ID of the user
1414
// Deprecated: use AppUserID instead, remove once all bots are migrated
1515
//AppUserIntID int64 `json:",omitempty" datastore:",omitempty" firestore:",omitempty"`
1616

17-
DtCreated time.Time `json:",omitempty" datastore:",omitempty" firestore:",omitempty"`
18-
DtUpdated time.Time `json:",omitempty" datastore:",omitempty" firestore:",omitempty"`
17+
DtCreated time.Time `json:"dtCreated" dalgo:"dtCreated" datastore:"dtCreated" firestore:"dtCreated"`
18+
DtUpdated time.Time `json:"dtUpdated" dalgo:"dtUpdated" datastore:"dtUpdated" firestore:"dtUpdated"`
1919

2020
// AccessGranted indicates if access to the bot has been granted
21-
AccessGranted bool
21+
AccessGranted bool `json:"isAccessGranted" dalgo:"isAccessGranted" datastore:"isAccessGranted" firestore:"isAccessGranted"`
2222
}
2323

2424
// Validate returns error if data is invalid
2525
func (e *BotBaseData) Validate() error {
26+
if e.AppUserID == "" {
27+
return validation.NewErrRecordIsMissingRequiredField("AppUserID")
28+
}
29+
if e.DtCreated.IsZero() {
30+
return validation.NewErrRecordIsMissingRequiredField("DtCreated")
31+
}
32+
if e.DtUpdated.IsZero() {
33+
return validation.NewErrRecordIsMissingRequiredField("dtUpdated")
34+
}
2635
if e.DtUpdated.Before(e.DtCreated) {
27-
return validation.NewErrBadRecordFieldValue("DtUpdated", "DtUpdated is before DtCreated")
36+
return validation.NewErrBadRecordFieldValue("dtUpdated", "is before dtCreated")
2837
}
29-
//if e.AppUserID != "" && e.AppUserIntID != 0 && strconv.FormatInt(e.AppUserIntID, 10) != e.AppUserID {
30-
// return validation.NewErrBadRecordFieldValue("AppUserIntID", "does not match AppUserID")
31-
//}
3238
return nil
3339
}
3440

botsfwmodels/bot_user_data.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ type BotUserBaseData struct {
77
BotBaseData
88
//user.LastLogin
99

10-
// FirstName is first name of a user
11-
FirstName string `json:",omitempty" dalgo:",omitempty,noindex"`
10+
// FirstName is the first name of a user
11+
FirstName string `json:"firstName,omitempty" firestore:"firstName,omitempty,noindex" dalgo:"firstName,omitempty,noindex"`
1212

13-
// LastName is last name of a user
14-
LastName string `json:",omitempty" dalgo:",omitempty,noindex"`
13+
// LastName is the last name of a user
14+
LastName string `json:"lastName,omitempty" firestore:"lastName,omitempty,noindex" dalgo:"lastName,omitempty,noindex"`
1515

1616
// UserName is login ID of a user
17-
UserName string `json:",omitempty" dalgo:",omitempty,noindex"`
17+
UserName string `json:"userName,omitempty" firestore:"userName,omitempty,noindex" dalgo:"userName,omitempty,noindex"`
1818
}
1919

2020
// BaseData returns base data of a user that should be included in all structs that implement BotUserData

botsfwmodels/chat_base_data_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ func TestBotChatEntity_PopStepsFromAwaitingReplyUpToSpecificParent(t *testing.T)
1010
chatEntity.AwaitingReplyTo = "step1/step2/step3"
1111
chatEntity.PopStepsFromAwaitingReplyUpToSpecificParent("step2")
1212
if chatEntity.AwaitingReplyTo != "step1/step2" {
13-
t.Errorf("Failed to remove last step3. AwaitingReplyTo: " + chatEntity.AwaitingReplyTo)
13+
t.Errorf("Failed to remove last step3. AwaitingReplyTo: %s", chatEntity.AwaitingReplyTo)
1414
}
1515

1616
chatEntity.AwaitingReplyTo = "step1/step2"
1717
chatEntity.PopStepsFromAwaitingReplyUpToSpecificParent("step2")
1818
if chatEntity.AwaitingReplyTo != "step1/step2" {
19-
t.Errorf("Failed to remove last step3. AwaitingReplyTo: " + chatEntity.AwaitingReplyTo)
19+
t.Errorf("Failed to remove last step3. AwaitingReplyTo: %s", chatEntity.AwaitingReplyTo)
2020
}
2121
}

0 commit comments

Comments
 (0)