Subject: | MUC Direct Messages Not handled [with patch] |
Direct messages to other occupants of a chat room aren't handled at all
by the MUC code. Relevant sections of xep-0045 are 7.8 and 7.9. I know
the MUC code isn't currently in the CPAN package but I wasn't sure of a
better place to post the patch.
Thanks,
Hans
]
===================================================================
--- DJabberd-MUC/lib/DJabberd/Plugin/MUC/Room.pm (revision 867)
+++ DJabberd-MUC/lib/DJabberd/Plugin/MUC/Room.pm (working copy)
@@ -92,11 +92,30 @@
$logger->error("User @{[$stanza->from]} is not a member of room
$self->{name}; dropping message.");
return;
}
+
$message_template->set_from("$self->{name}\@$self-
Show quoted text
>{domain}/$nickname");
- foreach my $member (keys %{$self->{members}}) {
- my $message = $message_template->clone;
- $message->set_to($self->{members}->{$member});
- $message->deliver($self->{vhost});
+ my $message_type = $stanza->attr( '{}type' );
+ # if message type = chat then it's to an individual. if type =
groupchat
+ # it's in the main room.
+ if ( $message_type eq 'groupchat' ) {
+ foreach my $member (keys %{$self->{members}}) {
+ my $message = $message_template->clone;
+ $message->set_to($self->{members}->{$member});
+ $message->deliver($self->{vhost});
+ }
+ } elsif ( $message_type eq 'chat' ) {
+ if ( $stanza->to =~ m/\/(.*)?$/ ) {
+ my $message = $message_template->clone;
+ my $to_jid = $self->{members}->{$1};
+ $message->set_to($to_jid);
+ $message->deliver($self->{vhost});
+ } else {
+ $logger->error("Direct message received without recipient
nick.");
+ return;
+ }
+ } else {
+ $logger->error("Unknown message type $message_type for MUC
message");
+ return;
}
}