3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 23:09:23 +01:00

relay: only join users once, returning if there are no queued users at all

Closes #71, prevents op floods on multiple SJOIN being sent. Also, this squashes AssertionErrors raised by protocol modules in sjoinServer, when we try to join zero users to a channel!
This commit is contained in:
James Lu 2015-07-25 11:00:55 -07:00
parent 7daa595a7b
commit b681a675eb

View File

@ -663,12 +663,18 @@ def relayJoins(irc, channel, users, ts, modes):
log.debug('Okay, spawning %s/%s everywhere', user, irc.name) log.debug('Okay, spawning %s/%s everywhere', user, irc.name)
assert user in irc.users, "(%s) How is this possible? %r isn't in our user database." % (irc.name, user) assert user in irc.users, "(%s) How is this possible? %r isn't in our user database." % (irc.name, user)
u = getRemoteUser(irc, remoteirc, user) u = getRemoteUser(irc, remoteirc, user)
# Only join users if they aren't already joined. This prevents op floods
# on charybdis from all the SJOINing.
if u not in remoteirc.channels[channel].users:
ts = irc.channels[channel].ts ts = irc.channels[channel].ts
# TODO: join users in batches with SJOIN, not one by one.
prefixes = getPrefixModes(irc, remoteirc, channel, user) prefixes = getPrefixModes(irc, remoteirc, channel, user)
userpair = (prefixes, u) userpair = (prefixes, u)
queued_users.append(userpair) queued_users.append(userpair)
log.debug('(%s) relayJoins: joining %s to %s%s', irc.name, userpair, remoteirc.name, remotechan) log.debug('(%s) relayJoins: joining %s to %s%s', irc.name, userpair, remoteirc.name, remotechan)
else:
log.debug('(%s) relayJoins: not joining %s to %s%s; they\'re already there!', irc.name,
u, remoteirc.name, remotechan)
if queued_users:
remoteirc.proto.sjoinServer(remoteirc, remoteirc.sid, remotechan, queued_users, ts=ts) remoteirc.proto.sjoinServer(remoteirc, remoteirc.sid, remotechan, queued_users, ts=ts)
relayModes(irc, remoteirc, irc.sid, channel, modes) relayModes(irc, remoteirc, irc.sid, channel, modes)