Skip to content

Commit

Permalink
add status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagleft committed May 30, 2022
1 parent 4a496dd commit c1dfccf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
37 changes: 25 additions & 12 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,6 @@ func (c *UtopiaClient) SendInstantMessage(to string, message string) (int64, err
return c.queryResultToInt("sendInstantMessage", params)
}

// ContactData - user contact data
type ContactData struct {
AuthStatus int `json:"authorizationStatus"`
AvatarHash string `json:"avatarMd5"`
Group string `json:"group"`
PubkeyHash string `json:"hashedPk"`
IsFriend bool `json:"isFriend"`
Nick string `json:"nick"`
Pubkey string `json:"pk"`
Status int `json:"status"`
}

// GetContacts - get account contacts
func (c *UtopiaClient) GetContacts(filter string) ([]ContactData, error) {
// send request
Expand Down Expand Up @@ -268,3 +256,28 @@ func (c *UtopiaClient) GetContacts(filter string) ([]ContactData, error) {

return contacts, nil
}

// IsOnline - is contact online?
func (d *ContactData) IsOnline() bool {
return d.Status == 4096
}

// IsOffline - is contact offline?
func (d *ContactData) IsOffline() bool {
return d.Status == 65536
}

// IsAway - is contact away?
func (d *ContactData) IsAway() bool {
return d.Status == 4097
}

// IsDoNotDisturb - is contact marked to do not disturb mode?
func (d *ContactData) IsDoNotDisturb() bool {
return d.Status == 4099
}

// IsInvisible - is contact invisible?
func (d *ContactData) IsInvisible() bool {
return d.Status == 32768
}
12 changes: 12 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ type WsSubscribeTask struct {
// optional
DisablePing bool
}

// ContactData - user contact data
type ContactData struct {
AuthStatus int `json:"authorizationStatus"`
AvatarHash string `json:"avatarMd5"`
Group string `json:"group"`
PubkeyHash string `json:"hashedPk"`
IsFriend bool `json:"isFriend"`
Nick string `json:"nick"`
Pubkey string `json:"pk"`
Status int `json:"status"` // 65536 - offline, 4096 - online, 4097 - away, 4099 - do not disturb, 32768 - invisible
}

0 comments on commit c1dfccf

Please sign in to comment.