Skip to content

Commit

Permalink
11.4: new methods ->do_modes() and ->do_modes_local() apply named mod…
Browse files Browse the repository at this point in the history
…es, notifying local users and other servers. #77. #101.
  • Loading branch information
cooper committed Jul 21, 2016
1 parent 6eca514 commit 49572c7
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
3 changes: 3 additions & 0 deletions INDEV
Original file line number Diff line number Diff line change
Expand Up @@ -3353,3 +3353,6 @@ CHANGES:

39. new server method ->strings_from_cmodes() generates one or more strings based on named modes. #101.
new configuration options channels:max_modes_per_line and channels:max_modes_per_sline determine how many modes can fit in an outgoing MODE message.

4. new methods ->do_modes() and ->do_modes_local() apply named modes, notifying local users and other servers. #77. #101.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.39
11.4
2 changes: 1 addition & 1 deletion modules/ircd.module/channel.module/channel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"no_bless" : 1,
"package" : "channel",
"preserve_sym" : 1,
"version" : "11.39"
"version" : "11.4"
}
65 changes: 62 additions & 3 deletions modules/ircd.module/channel.module/channel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,70 @@ sub prefixes {
return $prefixes;
}

# same as do_mode_string() except it never sends to other servers.
sub do_mode_string_local { _do_mode_string(1, @_) }
# handle named modes, tell our local users, and tell other servers.
sub do_modes { _do_modes(undef, @_) }

# same as ->do_modes() except it never sends to other servers.
sub do_modes_local { _do_modes(1, @_) }

# ->do_modes() and ->do_modes_local()
#
# See issue #101 for the planning of these methods.
#
# $source the source of the mode change
# $modes named modes in an arrayref as described in issue #101
# $force whether to ignore permissions
# $over_protocol specifies that the modes originated on incoming s2s
# $organize whether to alphabetize and put positive changes first
#
sub _do_modes {
my $local_only = shift;
my ($channel, $source, $modes, $force, $over_protocol, $organize) = @_;

# handle the mode.
# ($source, $modes, $force, $over_protocol) = @_;
my $changes = $channel->handle_modes(
$source, $modes, $force, $over_protocol
) or return;

# tell the channel's users. this might be sent as multiple messages.
#
# ->strings...($modes, $over_protocol, $split, $organize, $skip_checks)
# $over_protocol is false here because we want nicks rather than UIDs.
# $split is true here because we want to send multiple messages to users.
#
foreach ($me->strings_from_cmodes($changes, undef, 1, $organize, 1)) {
next unless length > 1;
$channel->sendfrom_all($source->full, "MODE $$channel{name} $_");
}

# stop here if it's not a local user or this server.
return if $local_only || !$source->is_local;

# the source is our user or this server, so tell other servers.
#
# ->strings...($modes, $over_protocol, $split, $organize, $skip_checks)
# $over_protocol is true here because we want UIDs rather than nicks.
# $split is false because we are generating a single mode string.
# currently each protocol implementation has to split it when necessary.
#
# cmode => ($source, $channel, $time, $perspective, $server_modestr)
#
my $server_str = $me->strings_from_cmodes($changes, 1, undef, $organize, 1);
$pool->fire_command_all(cmode =>
$source, $channel, $channel->{time},
$me, $server_str
);

return 1;
}

# handle a mode string, tell our local users, and tell other servers.
sub do_mode_string { _do_mode_string(undef, @_) }
sub do_mode_string { _do_mode_string(undef, @_) }

# same as ->do_mode_string() except it never sends to other servers.
sub do_mode_string_local { _do_mode_string(1, @_) }

sub _do_mode_string {
my ($local_only, $channel, $perspective, $source, $modestr, $force, $protocol) = @_;

Expand Down
2 changes: 1 addition & 1 deletion modules/ircd.module/server.module/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"no_bless" : 1,
"package" : "server",
"preserve_sym" : 1,
"version" : "11.39"
"version" : "11.4"
}
1 change: 0 additions & 1 deletion modules/ircd.module/server.module/server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ sub strings_from_cmodes {
$sort // $a->[1] cmp $b->[1]
} @changes if $organize;


# determine how much we can jam into one string.
my $limit =
!$split ? 'inf' : # no limit
Expand Down

0 comments on commit 49572c7

Please sign in to comment.