From 49f9b77bb269a164ebe34e54a57fd88407f74b92 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Wed, 6 Nov 2024 21:04:47 +0200 Subject: [PATCH] linkedingo,mapping: clean warnings --- pkg/connector/mapping.go | 3 --- pkg/linkedingo/client.go | 6 +++--- pkg/linkedingo/debug/logger.go | 2 +- pkg/linkedingo/messaging.go | 28 ++++++++++++++-------------- pkg/linkedingo/routing/endpoints.go | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/pkg/connector/mapping.go b/pkg/connector/mapping.go index 1d20374..cb63de9 100644 --- a/pkg/connector/mapping.go +++ b/pkg/connector/mapping.go @@ -132,9 +132,6 @@ func (lc *LinkedInClient) MessageToBackfillMessage(ctx context.Context, message sentAt := time.UnixMilli(message.DeliveredAt) intent := lc.userLogin.Bridge.Matrix.BotIntent() - if err != nil { - return nil, err - } cm, err := lc.convertToMatrix(ctx, portal, intent, &message) if err != nil { diff --git a/pkg/linkedingo/client.go b/pkg/linkedingo/client.go index 08ee448..23c2e94 100644 --- a/pkg/linkedingo/client.go +++ b/pkg/linkedingo/client.go @@ -81,12 +81,12 @@ func (c *Client) Logout() error { return err } - url := fmt.Sprintf("%s?%s", routing.LOGOUT_URL, string(encodedQuery)) + logoutUrl := fmt.Sprintf("%s?%s", routing.LOGOUT_URL, string(encodedQuery)) logoutDefinition := routing.RequestStoreDefinition[routing.LOGOUT_URL] headers := c.buildHeaders(logoutDefinition.HeaderOpts) - _, _, err = c.MakeRequest(url, http.MethodGet, headers, make([]byte, 0), logoutDefinition.ContentType) - c.Disconnect() + _, _, err = c.MakeRequest(logoutUrl, http.MethodGet, headers, make([]byte, 0), logoutDefinition.ContentType) + _ = c.Disconnect() c.cookies.Store = make(map[cookies.LinkedInCookieName]string) return err } diff --git a/pkg/linkedingo/debug/logger.go b/pkg/linkedingo/debug/logger.go index e981864..961e8fe 100644 --- a/pkg/linkedingo/debug/logger.go +++ b/pkg/linkedingo/debug/logger.go @@ -7,7 +7,7 @@ import ( "time" "github.com/mattn/go-colorable" - zerolog "github.com/rs/zerolog" + "github.com/rs/zerolog" ) var colors = map[string]string{ diff --git a/pkg/linkedingo/messaging.go b/pkg/linkedingo/messaging.go index 0781af0..e98d001 100644 --- a/pkg/linkedingo/messaging.go +++ b/pkg/linkedingo/messaging.go @@ -105,7 +105,7 @@ func (c *Client) FetchMessages(variables query.FetchMessagesVariables) (*respons } func (c *Client) EditMessage(messageUrn string, p payload.MessageBody) error { - url := fmt.Sprintf("%s/%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_MESSAGES_URL, url.QueryEscape(messageUrn)) + editMessageUrl := fmt.Sprintf("%s/%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_MESSAGES_URL, url.QueryEscape(messageUrn)) headerOpts := types.HeaderOpts{ WithCookies: true, @@ -132,7 +132,7 @@ func (c *Client) EditMessage(messageUrn string, p payload.MessageBody) error { return err } - resp, respBody, err := c.MakeRequest(url, http.MethodPost, headers, payloadBytes, types.PLAINTEXT_UTF8) + resp, respBody, err := c.MakeRequest(editMessageUrl, http.MethodPost, headers, payloadBytes, types.PLAINTEXT_UTF8) if err != nil { return err } @@ -185,11 +185,11 @@ func (c *Client) StartTyping(conversationUrn string) error { Action: query.ACTION_TYPING, } - payload := payload.StartTypingPayload{ + typingPayload := payload.StartTypingPayload{ ConversationUrn: conversationUrn, } - resp, _, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, payload, actionQuery) + resp, _, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, typingPayload, actionQuery) if err != nil { return err } @@ -206,11 +206,11 @@ func (c *Client) DeleteMessage(messageUrn string) error { Action: query.ACTION_RECALL, } - payload := payload.DeleteMessagePayload{ + deleteMsgPayload := payload.DeleteMessagePayload{ MessageUrn: messageUrn, } - resp, _, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_DASH_MESSENGER_MESSAGES_URL, payload, actionQuery) + resp, _, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_DASH_MESSENGER_MESSAGES_URL, deleteMsgPayload, actionQuery) if err != nil { return err } @@ -243,12 +243,12 @@ func (c *Client) MarkThreadRead(conversationUrns []string, read bool) (*response } queryStr := fmt.Sprintf("ids=List(%s)", queryUrnValues) - url := fmt.Sprintf("%s?%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, queryStr) - payload := payload.PatchEntitiesPayload{ + markReadUrl := fmt.Sprintf("%s?%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, queryStr) + patchEntitiesPayload := payload.PatchEntitiesPayload{ Entities: entities, } - payloadBytes, err := payload.Encode() + payloadBytes, err := patchEntitiesPayload.Encode() if err != nil { return nil, err } @@ -265,7 +265,7 @@ func (c *Client) MarkThreadRead(conversationUrns []string, read bool) (*response } headers := c.buildHeaders(headerOpts) - resp, respBody, err := c.MakeRequest(url, http.MethodPost, headers, payloadBytes, types.PLAINTEXT_UTF8) + resp, respBody, err := c.MakeRequest(markReadUrl, http.MethodPost, headers, payloadBytes, types.PLAINTEXT_UTF8) if err != nil { return nil, err } @@ -279,7 +279,7 @@ func (c *Client) MarkThreadRead(conversationUrns []string, read bool) (*response } func (c *Client) DeleteConversation(conversationUrn string) error { - url := fmt.Sprintf("%s/%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, url.QueryEscape(conversationUrn)) + deleteConvUrl := fmt.Sprintf("%s/%s", routing.VOYAGER_MESSAGING_DASH_MESSENGER_CONVERSATIONS_URL, url.QueryEscape(conversationUrn)) headers := c.buildHeaders(types.HeaderOpts{ WithCookies: true, @@ -294,7 +294,7 @@ func (c *Client) DeleteConversation(conversationUrn string) error { }, }) - resp, _, err := c.MakeRequest(url, http.MethodDelete, headers, nil, types.NONE) + resp, _, err := c.MakeRequest(deleteConvUrl, http.MethodDelete, headers, nil, types.NONE) if err != nil { return err } @@ -334,12 +334,12 @@ func (c *Client) GetReactionsForEmoji(vars query.GetReactionsForEmojiVariables) return nil, err } - query := query.GraphQLQuery{ + gqlQuery := query.GraphQLQuery{ QueryID: "messengerMessagingParticipants.3d2e0e93494e9dbf4943dc19da98bdf6", Variables: string(variablesQuery), } - _, respData, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_GRAPHQL_URL, nil, &query) + _, respData, err := c.MakeRoutingRequest(routing.VOYAGER_MESSAGING_GRAPHQL_URL, nil, &gqlQuery) if err != nil { return nil, err } diff --git a/pkg/linkedingo/routing/endpoints.go b/pkg/linkedingo/routing/endpoints.go index 87c408e..1d6490f 100644 --- a/pkg/linkedingo/routing/endpoints.go +++ b/pkg/linkedingo/routing/endpoints.go @@ -6,7 +6,7 @@ type RequestEndpointURL string const ( BASE_URL RequestEndpointURL = "https://" + BASE_HOST - MESSAGES_BASE_URL RequestEndpointURL = BASE_URL + "/messaging" + MESSAGES_BASE_URL = BASE_URL + "/messaging" VOYAGER_GRAPHQL_URL = BASE_URL + "/voyager/api/graphql" VOYAGER_COMMON_ME_URL = BASE_URL + "/voyager/api/me" VOYAGER_MESSAGING_GRAPHQL_URL = BASE_URL + "/voyager/api/voyagerMessagingGraphQL/graphql"