Skip to content

Commit

Permalink
feat: AppUserAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
trakhimenok committed Nov 26, 2023
1 parent 261b817 commit 3d8a1e1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
12 changes: 12 additions & 0 deletions botsfwmodels/app_user_adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package botsfwmodels

type AppUserAdapter interface {
// SetBotUserID associates bot user ID with an app user record
SetBotUserID(platform, botID, botUserID string)

// UserNamesHolder is an interface to set and get user's names.
UserNamesHolder

// PreferredLocaleHolder is an interface to set and get preferred locale
PreferredLocaleHolder
}
30 changes: 12 additions & 18 deletions botsfwmodels/app_user_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ package botsfwmodels
// Bots can use it to store information about a user like names, preferred locale.
type AppUserData interface {

// SetBotUserID associates bot user ID with an app user record
SetBotUserID(platform, botID, botUserID string)

// UserNamesHolder is an interface to set and get user's names.
UserNamesHolder

// PreferredLocaleHolder is an interface to set and get preferred locale
PreferredLocaleHolder
// BotsFwAdapter returns to bots framework an adapter to app user data record.
// Using an adapter ensures there is no clashes between bots framework interfaces and app user struct.
BotsFwAdapter() AppUserAdapter
}

type UserNamesHolder interface {
// SetName sets a name of a user. It is used to store first name, last name, etc.
// Parameters:
// - field: name of a field to set: "firstName", "lastName", "nickName", "fullName"
SetName(field, value string) error

// GetName returns a name of a user. It is used to store first name, last name, etc.
// Parameters:
// - field: name of a field to set: "firstName", "lastName", "nickName", "fullName"
GetName(field string) string
// SetNames sets names of a user.
SetNames(firstName, lastName, fullName string) error

// GetFullName returns full name of a user
GetFullName() string
//// GetName returns a name of a user. It is used to store first name, last name, etc.
//// Parameters:
//// - field: name of a field to set: "firstName", "lastName", "nickName", "fullName"
//GetName(field string) string
//
//// GetFullName returns full name of a user
//GetFullName() string
}
2 changes: 1 addition & 1 deletion botsfwmodels/chat_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (e *chatState) PopStepsFromAwaitingReplyUpToSpecificParent(step string) {
//steps = steps[:i]
break
// } else {
// log.Infof(c, "steps[%v]: %v != %v:", i, steps[i], step)
// logMessage.Infof(c, "steps[%v]: %v != %v:", i, steps[i], step)
}
}
}
Expand Down

0 comments on commit 3d8a1e1

Please sign in to comment.