Skip to content

Commit a23b35d

Browse files
committed
presence: add client nil error
1 parent c8a3f70 commit a23b35d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

presence.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ func (cli *Client) handlePresence(node *waBinary.Node) {
6262
// You should call this at least once after connecting so that the server has your pushname.
6363
// Otherwise, other users will see "-" as the name.
6464
func (cli *Client) SendPresence(state types.Presence) error {
65-
if len(cli.Store.PushName) == 0 {
65+
if cli == nil {
66+
return ErrClientIsNil
67+
} else if len(cli.Store.PushName) == 0 {
6668
return ErrNoPushName
6769
}
6870
if state == types.PresenceAvailable {
@@ -88,6 +90,9 @@ func (cli *Client) SendPresence(state types.Presence) error {
8890
//
8991
// cli.SendPresence(types.PresenceAvailable)
9092
func (cli *Client) SubscribePresence(jid types.JID) error {
93+
if cli == nil {
94+
return ErrClientIsNil
95+
}
9196
privacyToken, err := cli.Store.PrivacyTokens.GetPrivacyToken(context.TODO(), jid)
9297
if err != nil {
9398
return fmt.Errorf("failed to get privacy token: %w", err)

0 commit comments

Comments
 (0)