-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix: this.state.chans and channel.users are Map type, not an Object type #103
Fix: this.state.chans and channel.users are Map type, not an Object type #103
Conversation
iwalkalone69
commented
May 2, 2023
- Object.entries(this.state.chans) is not working as it is a Map, it returns an empty array.
- message.nick in killChannel.users is not working as it is a Map too. Repacing with Map.prototype.has().
- Replacing delete killChannel.users[message.nick] with Map.prototype.delete().
- Doing the same with quitChannel.
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.
Change looks good, but can you:
- Sign off, as per https://github.com/matrix-org/matrix-appservice-bridge/blob/develop/CONTRIBUTING.md#%EF%B8%8F-pull-requests
- Write a changelog summarizing what you've fixed
Optionally, a test would be good to avoid this. We have a nice example in
Lines 30 to 41 in 96e1cdd
test('can join a channel and send a message', async () => { | |
const { speaker, listener } = server.clients; | |
await listener.join('#foobar'); | |
const messagePromise = listener.waitForEvent('message'); | |
await speaker.join('#foobar'); | |
await speaker.say('#foobar', 'Hello world!'); | |
const [nick, channel, text] = await messagePromise; | |
expect(nick).toBe(speaker.nick); | |
expect(channel).toBe('#foobar'); | |
expect(text).toBe('Hello world!'); | |
}); |
Signed-off-by: iwalkalone <iwalkalone69@gmail.com>
So that's why appservice-irc stopped bridging quits months ago! Thanks @iwalkalone69! |
Did you check |
I didn't check it yet, but probably it will need too. If I can confirm and check it will submit another PR. |
…ick() function Signed-off-by: iwalkalone <iwalkalone69@gmail.com>
I have committed another change that fixes this. It uses Map.prototype.forEach() to iterate channels. |
Incidentally I think this sort of thing really needs a linting rule, but alas there isn't one yet typescript-eslint/typescript-eslint#6807 |
src/irc.ts
Outdated
nickChannel.users.set(message.args[0], chanUser); | ||
this.state.chans.forEach((nickChannel, channame) => { | ||
if (message.nick && nickChannel.users.has(message.nick)) { | ||
nickChannel.users.set(message.args[0], nickChannel.users.get(message.nick)); |
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.
Seems like there is a typing fail here?
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.
Yes, sorry. It is fixed now.
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 bugfix :)