-
Notifications
You must be signed in to change notification settings - Fork 1
Image Forwarding #6
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, good job working on this.
I noticed that there's no support for ImageMessageEvent
in manager, let's add it too:
https://github.com/dstdfx/twbridge/blob/main/internal/manager/clients_manager.go#L55
I addressed all the requested changes and pushed. However when I added the new case in clients_manager.go for ImageMessageEvent I now get a linting error regarding cyclomatic complexity: internal/manager/clients_manager.go:42:1: cyclomatic complexity 31 of func |
We can divide this For now, we can just fix the limit by adding this to the
|
} | ||
|
||
if err := eventsHandler.HandleImageMessageEvent(e); err != nil { | ||
mgr.log.Error("failed to handle text message event", zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text
-> image
return fmt.Errorf("failed to send image message chat_id=%d: %w", | ||
event.ChatID, | ||
err) | ||
return fmt.Errorf("failed to notify telegram: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep failed to send image message
, the idea is to extend the context of the error, this would save us time later if we need to debug it
|
||
// Download media data | ||
mediaData, err := message.Download() | ||
if err != nil { | ||
wh.log.Error("got error", zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be more specific here, for example: "failed to download media data" + error field
Sorry just returning to this but. I don't see a .golangcilint.yml . Only .golangci.yml. Should i create the dot file or add to .golanci ? |
You're right, it's called |
For #1
"""
First pull request ever so not sure what convention is or what is generally required. Open to feedback. Will detail code changes here...
Also disregard branch name. This is for image forwarding.
"""
Wasn't able to test but I add ImageEvent to domain/domain.go that contains ImageBytes[].
These are obtained from whatsapp.ImageMessage.download() which is called in newly added HandleImageMessage() in events_provider.go
This is then passed to the telegram api and uploaded in similiar manner to QR code.
Hope this works!