Skip to content

Commit

Permalink
linkedingo,mapping: clean warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpShell committed Nov 6, 2024
1 parent 5a98278 commit 49f9b77
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions pkg/connector/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/linkedingo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/linkedingo/debug/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
28 changes: 14 additions & 14 deletions pkg/linkedingo/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/linkedingo/routing/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 49f9b77

Please sign in to comment.