{"action":"created","issue":{"url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/104","repository_url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc","labels_url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/104/comments","events_url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/104/events","html_url":"https://github.com/matrix-org/matrix-appservice-irc/issues/104","id":166057486,"number":104,"title":"Implement kick and ban mirroring","user":{"login":"Kegsay","id":7190048,"avatar_url":"https://avatars.githubusercontent.com/u/7190048?v=3","gravatar_id":"","url":"https://api.github.com/users/Kegsay","html_url":"https://github.com/Kegsay","followers_url":"https://api.github.com/users/Kegsay/followers","following_url":"https://api.github.com/users/Kegsay/following{/other_user}","gists_url":"https://api.github.com/users/Kegsay/gists{/gist_id}","starred_url":"https://api.github.com/users/Kegsay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kegsay/subscriptions","organizations_url":"https://api.github.com/users/Kegsay/orgs","repos_url":"https://api.github.com/users/Kegsay/repos","events_url":"https://api.github.com/users/Kegsay/events{/privacy}","received_events_url":"https://api.github.com/users/Kegsay/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/labels/feature-req","name":"feature-req","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"Kegsay","id":7190048,"avatar_url":"https://avatars.githubusercontent.com/u/7190048?v=3","gravatar_id":"","url":"https://api.github.com/users/Kegsay","html_url":"https://github.com/Kegsay","followers_url":"https://api.github.com/users/Kegsay/followers","following_url":"https://api.github.com/users/Kegsay/following{/other_user}","gists_url":"https://api.github.com/users/Kegsay/gists{/gist_id}","starred_url":"https://api.github.com/users/Kegsay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kegsay/subscriptions","organizations_url":"https://api.github.com/users/Kegsay/orgs","repos_url":"https://api.github.com/users/Kegsay/repos","events_url":"https://api.github.com/users/Kegsay/events{/privacy}","received_events_url":"https://api.github.com/users/Kegsay/received_events","type":"User","site_admin":false},"assignees":[{"login":"Kegsay","id":7190048,"avatar_url":"https://avatars.githubusercontent.com/u/7190048?v=3","gravatar_id":"","url":"https://api.github.com/users/Kegsay","html_url":"https://github.com/Kegsay","followers_url":"https://api.github.com/users/Kegsay/followers","following_url":"https://api.github.com/users/Kegsay/following{/other_user}","gists_url":"https://api.github.com/users/Kegsay/gists{/gist_id}","starred_url":"https://api.github.com/users/Kegsay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kegsay/subscriptions","organizations_url":"https://api.github.com/users/Kegsay/orgs","repos_url":"https://api.github.com/users/Kegsay/repos","events_url":"https://api.github.com/users/Kegsay/events{/privacy}","received_events_url":"https://api.github.com/users/Kegsay/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-07-18T09:50:05Z","updated_at":"2016-07-28T10:15:48Z","closed_at":null,"body":"Semantics time!\r\n\r\n### Kicking\r\nIRC and Matrix operate in basically the same way here:\r\n```\r\nKICK <channel> <client> [<message>]\r\n```\r\nvs\r\n```\r\nPOST /_matrix/client/r0/rooms/{roomId}/kick\r\nContent-Type: application/json\r\n\r\n{\r\n  \"reason\": <message>,\r\n  \"user_id\": <client>\r\n}\r\n```\r\n\r\nIRC-side, this comes down as a `KICK` command with `\"args\":[\"#channel\",\"$KICKEE\",\"$KICKER\"]`. We can trivially map this across on dynamically-bridged channels. However, on statically mapped rooms the bot may not have enough power to be able to mirror kicks. How we bridge power for this is another question. \r\n\r\n### Banning\r\nThere is a bit of a discrepancy here. On IRC, you have to \"kickban\" - that is, set a ban mask for the username/host/nick and then kick them from the channel. On Matrix, banning someone also kicks them from the room, so we *cannot* just mirror across `MODE` commands with `+b` which look like: \r\n\r\n```\r\n2016-07-18 09:40:50 DEBUG:client-connection albalbfla@localhost: {\"prefix\":\"kegan!~kegan@echo-69205055\",\"nick\":\"kegan\",\"user\":\"~kegan\",\"host\":\"echo-69205055\",\"command\":\"MODE\",\"rawCommand\":\"MODE\",\"commandType\":\"normal\",\"args\":[\"#ktest\",\"+b\",\"*!~foobar2lo@echo-69205055\"]}\r\n```\r\n\r\nHowever, if we mirror *kicks* then the \"kick\" part of the kickban will then evict the user from the room. When they attempt to rejoin they will get this response from the IRCd:\r\n\r\n```\r\n2016-07-18 09:41:14 DEBUG:client-connection albalbfla@localhost: {\"prefix\":\"echo.local\",\"server\":\"echo.local\",\"command\":\"err_bannedfromchan\",\"rawCommand\":\"474\",\"commandType\":\"error\",\"args\":[\"albalbfla\",\"#ktest\",\"Cannot join channel (+b)\"]}\r\n```\r\n\r\nAnd this we can then use as the trigger for assigning the \"ban\". We currently [have a problem](https://github.com/matrix-org/matrix-appservice-irc/issues/25) where bans may not be honoured on dynamic channels because we can't prevent the user from joining a public room *via an alias* (there's no mechanism for rejecting *them* without creating the link). However, by adding in the trigger for `err_bannedfromchan`, this will magically work (because Matrix bans will also kick them from the room *and* assign a ban). So we can mirror bans from IRC to Matrix. From Matrix to IRC, we will need the bridge to \"kickban\" when the bridge receives a Matrix ban (kick banning based on the ident username).\r\n\r\n\r\nHow we bridge power levels / ops is [an open question](https://github.com/matrix-org/matrix-appservice-irc/issues/46), but is not one we need to resolve in order to service \"portal\"-based dynamic channels."},"comment":{"url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/comments/235855987","html_url":"https://github.com/matrix-org/matrix-appservice-irc/issues/104#issuecomment-235855987","issue_url":"https://api.github.com/repos/matrix-org/matrix-appservice-irc/issues/104","id":235855987,"user":{"login":"Kegsay","id":7190048,"avatar_url":"https://avatars.githubusercontent.com/u/7190048?v=3","gravatar_id":"","url":"https://api.github.com/users/Kegsay","html_url":"https://github.com/Kegsay","followers_url":"https://api.github.com/users/Kegsay/followers","following_url":"https://api.github.com/users/Kegsay/following{/other_user}","gists_url":"https://api.github.com/users/Kegsay/gists{/gist_id}","starred_url":"https://api.github.com/users/Kegsay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kegsay/subscriptions","organizations_url":"https://api.github.com/users/Kegsay/orgs","repos_url":"https://api.github.com/users/Kegsay/repos","events_url":"https://api.github.com/users/Kegsay/events{/privacy}","received_events_url":"https://api.github.com/users/Kegsay/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T10:15:48Z","updated_at":"2016-07-28T10:15:48Z","body":"So we now bridge kicks (#111), we just need semantics for bans.\r\n\r\nBanmasks are really really hard to map to matrix because they look like this:\r\n```\r\n/mode #channel +b nickname!ident@hostname.here\r\n```\r\nSo you can ban based on nick, ident username, or even host. It also supports wildcards(!). I don't want to have to port the entire IRCd algorithm for matching banmasks to the bridge. However! We may not have to...\r\n\r\nIf we make the (not unreasonable) assumption that if you set a banmask for a user, you will then kick them (kickbanning), then when they try to rejoin they will get `err_bannedfromchan` errors.  We already mirror kicks correctly now. Therefore, we only need to see if we get `err_bannedfromchan` errors, and if so, send a `/ban` to the Matrix user! No wildcards required!\r\n\r\nHowever... we need to know when they get unbanned. This is a huge problem because the IRC bridge **will not get join attempts** if you're banned (no events are sent to the bridge), so we can't just try to rejoin the channel every time the Matrix user tries to join the channel. This does seem to implicate some degree of banmask parsing in order to determine when the ban is lifted, so the bridge can unban the Matrix side :(\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"Kegsay"}}