connector/reactions: return error if not logged in
Previously, the getAvailableReactions function was only called with a logged in client. However, now that it is called in the GetCapabilities call, the client is no longer guaranteed to be logged in. This was causing an NPE due to the (*TelegramClient).client being nil. This commit makes the getAvailableReactions function not panic when the client is not logged in. Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package connector
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -907,6 +908,10 @@ func (t *TelegramClient) getAvailableReactionsForCapability(ctx context.Context)
|
||||
}
|
||||
|
||||
func (t *TelegramClient) getAvailableReactions(ctx context.Context) (map[string]struct{}, error) {
|
||||
if !t.IsLoggedIn() {
|
||||
return nil, errors.New("you must be logged in to get available reactions")
|
||||
}
|
||||
|
||||
log := zerolog.Ctx(ctx).With().Str("handler", "get_available_reactions").Logger()
|
||||
t.availableReactionsLock.Lock()
|
||||
defer t.availableReactionsLock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user