@@ -821,45 +821,61 @@ - (void)destroyRoom
821
821
#pragma mark Messages
822
822
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
823
823
824
- - (void )inviteUser : (XMPPJID *)jid withMessage : (NSString *)inviteMessageStr
824
+ - (void )inviteUser : (XMPPJID *)jid withMessage : (NSString *)invitationMessage
825
825
{
826
- dispatch_block_t block = ^{ @autoreleasepool {
827
-
828
- XMPPLogTrace ();
829
-
830
- // <message to='[email protected] '>
831
- // <x xmlns='http://jabber.org/protocol/muc#user'>
832
- // <invite to='[email protected] '>
833
- // <reason>
834
- // Hey Hecate, this is the place for all good witches!
835
- // </reason>
836
- // </invite>
837
- // </x>
838
- // </message>
839
-
840
- NSXMLElement *invite = [NSXMLElement elementWithName: @" invite" ];
841
- [invite addAttributeWithName: @" to" stringValue: [jid full ]];
842
-
843
- if ([inviteMessageStr length ] > 0 )
844
- {
845
- [invite addChild: [NSXMLElement elementWithName: @" reason" stringValue: inviteMessageStr]];
846
- }
847
-
848
- NSXMLElement *x = [NSXMLElement elementWithName: @" x" xmlns: XMPPMUCUserNamespace];
849
- [x addChild: invite];
850
-
851
- XMPPMessage *message = [XMPPMessage message ];
852
- [message addAttributeWithName: @" to" stringValue: [roomJID full ]];
853
- [message addChild: x];
854
-
855
- [xmppStream sendElement: message];
856
-
857
- }};
858
-
859
- if (dispatch_get_specific (moduleQueueTag))
860
- block ();
861
- else
862
- dispatch_async (moduleQueue, block);
826
+ [self inviteUsers: @[jid] withMessage: invitationMessage];
827
+ }
828
+
829
+ - (void )inviteUsers : (NSArray <XMPPJID *> *)jids withMessage : (NSString *)invitationMessage
830
+ {
831
+ dispatch_block_t block = ^{ @autoreleasepool {
832
+
833
+ XMPPLogTrace ();
834
+
835
+ // <message to='[email protected] '>
836
+ // <x xmlns='http://jabber.org/protocol/muc#user'>
837
+ // <invite to='[email protected] '>
838
+ // <reason>
839
+ // Invitation message
840
+ // </reason>
841
+ // </invite>
842
+ // <invite to='<invite to='[email protected] '/>'>
843
+ // <reason>
844
+ // Invitation message
845
+ // </reason>
846
+ // </invite>
847
+ // </x>
848
+ // </message>
849
+
850
+ NSXMLElement *x = [NSXMLElement elementWithName: @" x" xmlns: XMPPMUCUserNamespace];
851
+
852
+ for (XMPPJID *jid in jids) {
853
+ DDXMLElement *invite = [self inviteElementWithJid: jid invitationMessage: invitationMessage];
854
+ [x addChild: invite];
855
+ }
856
+
857
+ XMPPMessage *message = [XMPPMessage message ];
858
+ [message addAttributeWithName: @" to" stringValue: [roomJID full ]];
859
+ [message addChild: x];
860
+
861
+ [xmppStream sendElement: message];
862
+
863
+ }};
864
+
865
+ if (dispatch_get_specific (moduleQueueTag))
866
+ block ();
867
+ else
868
+ dispatch_async (moduleQueue, block);
869
+ }
870
+
871
+ - (DDXMLElement *)inviteElementWithJid : (XMPPJID *)jid invitationMessage : (NSString *)invitationMessage {
872
+ NSXMLElement *invite = [NSXMLElement elementWithName: @" invite" ];
873
+ [invite addAttributeWithName: @" to" stringValue: [jid full ]];
874
+
875
+ if ([invitationMessage length ] > 0 ) {
876
+ [invite addChild: [NSXMLElement elementWithName: @" reason" stringValue: invitationMessage]];
877
+ }
878
+ return invite;
863
879
}
864
880
865
881
- (void )sendMessage : (XMPPMessage *)message
0 commit comments