-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WhatsApp support #711
WhatsApp support #711
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.
Found some fixes!
P.S. share your ideas, feedbacks or issues with us at https://github.com/fixmie/feedback (this message will be removed after the beta stage).
First of all, great job! Even more if this is your first go program 👍 Regarding the PR, some general comments before I look at the code:
We're are also using golangci-lint for linting the code, I suggest you install this and run it from the matterbridge directory. It'll show you what needs to be improved. If some of this output isn't clear, don't hesitate to ask for help here or on the chat. |
On it, thank you! My main concern right now is a UI one: a channel on Slack is shown as a unique ID string of the WhatsApp channel, which doesn't look great. I have to use unique IDs for groups, because WhatsApp allows for non-unique group names. I'm wondering if there is any possibility that in the config file there will be group ID, but Slack (and other bridges) would show some kind of group label? Did you have such problem for any of the other bridges/chats? |
Shouldn't downloading vendors be part of the build process? Keeping vendor files that can be accessed remotely in this repo sounds like a bad practice to me. |
Question: When In WhatsApp I can |
I separated also a |
Some quick comments, later some more :-)
|
|
But please hold some time with merging that in. I see that it is quite easy for telephone numbers to be exposed via relay. There might be no way around it, but at least I'd like to research that a little bit more and document for users to be aware of. #unintentedconsequences |
I don't understand this: "a channel on Slack is shown".
You mean by running with
Ok, please also remove the large commented part in the Send() in whatsapp.go and the slack references in New(). You also probably won't need the lru cache. |
Sorry, I should have had elaborated more. One photo is worth a thousand words: 1. Channel Label
I'm using a I don't know if WhatsApp is the first case of long unique channel id or did you have this issue before? What I'd love to have is an ability to set a channel label that would be used here instead of channel id when set.
That would result in above RemoteNickFormat to be formatted as 2. Unintended consequences
WhatsApp primarily identify users by telephone numbers. Altough internally there are independent unique ids being used, still I saw that telephone numbers pop out here and then. To bring the picture again: Exposing numbers happens in two places (that I found so far):
While for WhatsApp using numbers is natural, relaying messages to many other bridges is an issue in my opinion. Ppl might not want their phone numbers to be exposed to "strangers" on public chats. How was it solved in Telegram? Issue 1 could be solved by above That made me also think about the EU's GDPR regulations and user consent before you share any of their personal data, but that's a bigger topic. Thinking further into unintended consequences.. WhatsApp imposed a maximum limit of members in the group to stop disinformation from spreading. Disinfo bubbles spreading via WhatsApp groups and forwarding resulted in killings in India and Philippines. This bridge overcomes some of those limits. How do we address it? I might start another issue for #unintentedconsequences. Maybe do a review along https://ethicalos.org/ guidelines. 3. Code
Cleaned the code.
Where is the race? I write to it in one place and time, and then only read from them. But for the future I will need to update them as ppl join the channels, so suggestion how to guard races would be welcomed. |
Perhaps related to "1. channel label" aspect: #614 A robust templating engine would allow people to set a high-level default RemoteNickFormat that took special-cases into account, without solving it in core: [{% label %}{% #if protocol != "whatsapp" %} #{% channel %}{% /if %}] @{% nick %} Note: The above is a made-up pseudo language. |
Well, I think using {CHANNEL} in But I agree if you do use it, a channel-label feature would be nice (but it doesn't exist).
A possible hack to achieve this is to create a new whatsapp bridge per channel, this way you can use the existing
Afaik telegram always returns a name and if the name is empty (when a user hasn't set a public name) we return "unknownUser" matterbridge/bridge/telegram/handlers.go Lines 102 to 105 in 5af1d80
I don't use telegram myself, so I haven't seen this in action.
Sounds good.
You raise some good points, but I have no idea how we could control this. I think this point should also be raised at the library, maybe messages have a "forwarding" count somewhere. Another option here is to detect if the message is a forwarded message and drop it (but anyway who wants to overrule this can just modify the code).
The one in users map that I thought isn't there, you're indeed not writing again to the users map. You can run
Look at the slack bridge, it adds a mutex matterbridge/bridge/slack/slack.go Line 34 in 5af1d80
Which then get a R(ead)Lock when data is read, and a Lock when you also write data to your map matterbridge/bridge/slack/helpers.go Lines 14 to 26 in 5af1d80
So you best use those functions to modify/read the map instead of directly accessing the map. Regarding the PR itself some small nitpicks left before it can be merged:
|
Channel Label
I use Matterbridge to link different communities together. I'd like them to know where does message originated from so they can head to another chat to get into 1-on-1 direct messages or other channels that are not relayed. It's true though that in most cases the channel names are very similar. I might drop it for simplicity and to solve above problem temporarily.
I've separated it into an issue, will work on it in the free time -> #725 Code
What you said is true, but I don't see there any race conditions. The write function fills in the map at its own pace. It is the only thread that does the writing. The message handler reads from the usersAvatars - it will either:
The setting of the url is done at once in the map, atomically, so no need to guard writing there. I understand that Slack might need mutexes because you have multiple writers. Each message being handled might result in modifying the users map. Here there is no such issue
I added it to make it harder to accidentally add developer's
It is not neccessary, but it was making the code cleaner for me. Removed. |
Thanks for the changes. For me the current code can be merged, let me know if it's ok for you too.
Made a simple example of the issue on https://play.golang.org/p/ow2ik2qoTNA |
It's good to go from my side. Thank you a lot for taking the time to peer-review it! |
Maybe handy to make a example how to save the session file with a volume (For Docker). |
@Tjird I'm not an expert of Docker, could you propose a I added a mention of the need to store the session file to Azure deploy's guide https://github.com/42wim/matterbridge/wiki/Deploy:-Azure |
@KrzysztofMadejski I'm making a PR myself for that small thing if this PR is merged. |
Let's party! 👍 |
Alpha version. Discussion is on #475