pull/651/head
Darien Raymond 2017-08-24 22:56:31 +02:00
parent 1c2b6d9536
commit 7392bb495b
1 changed files with 7 additions and 13 deletions

View File

@ -2,18 +2,12 @@ package protocol
import "time"
var (
ErrAccountMissing = newError("Account is not specified.")
ErrNonMessageType = newError("Not a protobuf message.")
ErrUnknownAccountType = newError("Unknown account type.")
)
func (v *User) GetTypedAccount() (Account, error) {
if v.GetAccount() == nil {
return nil, ErrAccountMissing
func (u *User) GetTypedAccount() (Account, error) {
if u.GetAccount() == nil {
return nil, newError("Account missing").AtWarning()
}
rawAccount, err := v.Account.GetInstance()
rawAccount, err := u.Account.GetInstance()
if err != nil {
return nil, err
}
@ -23,12 +17,12 @@ func (v *User) GetTypedAccount() (Account, error) {
if account, ok := rawAccount.(Account); ok {
return account, nil
}
return nil, newError("Unknown account type: ", v.Account.Type)
return nil, newError("Unknown account type: ", u.Account.Type)
}
func (v *User) GetSettings() UserSettings {
func (u *User) GetSettings() UserSettings {
settings := UserSettings{}
switch v.Level {
switch u.Level {
case 0:
settings.PayloadTimeout = time.Second * 30
case 1: