Xmpp bookmark auto-replace option not working

I'm trying to automatically join rooms using XEP-0048 - Bookmarks ( http://xmpp.org/extensions/xep-0048.html ).

I am using RobbieHanson XMPPFramework, ejabberd v13.x So far I have managed to add a bookmark to the room using the following code:

-(void) createBookmarkforRoom:(NSString *)roomJid {
    NSXMLElement *nick = [NSXMLElement elementWithName:@"nick" stringValue:@"Marge"];

    NSXMLElement *conference = [DDXMLNode elementWithName:@"conference"];
    [conference addAttributeWithName:@"name" stringValue:@"BookmarkName"];
    [conference addAttributeWithName:@"autojoin" stringValue:@"true"];
    [conference addAttributeWithName:@"jid" stringValue:roomJid];

    [conference addChild:nick];

    NSXMLElement *storage =[DDXMLNode elementWithName:@"storage"];
    [storage addAttributeWithName:@"xmlns" stringValue:@"storage:bookmarks"];

    [storage addChild:conference];

    NSDictionary *options = [NSDictionary dictionaryWithObjects:@[@"pubsub#persist_items",@"pubsub#access_model"]
                                                    forKeys:@[@"true",@"whitelist"]];

    [self.publishSubscribeModule publishToNode:@"storage:bookmarks"
                                     entry:(NSXMLElement *)storage
                                withItemID:(NSString *)@"current"
                                   options:(NSDictionary *)options];

}

The following xml was sent successfully:

<iq type="set" id="2749368B-E365-45D6-A4B0-2F79DC6F4747">
   <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <publish node="storage:bookmarks">
         <item id="current">
            <storage xmlns="storage:bookmarks">
               <conference name="BookmarkName" autojoin="true" jid="testroom@conference.mydomain.com">
                  <nick>Marge</nick>
               </conference>
            </storage>
         </item>
      </publish>
      <publish-options>
         <x xmlns="jabber:x:data" type="submit">
            <field var="FORM_TYPE" type="hidden">
               <value>http://jabber.org/protocol/pubsub#publish-options</value>
            </field>
            <field var="true">
               <value>pubsub#persist_items</value>
            </field>
            <field var="whitelist">
               <value>pubsub#access_model</value>
            </field>
         </x>
      </publish-options>
   </pubsub>
</iq>

And I get:

<iq xmlns="jabber:client" from="marge@mydomain.com" to="marge@mydomain.com/41045582821403862604272126" id="2749368B-E365-45D6-A4B0-2F79DC6F4747" type="result">
   <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <publish node="storage:bookmarks">
         <item id="current" />
      </publish>
   </pubsub>
</iq>

When I try to get bookmarks using the following code:

-(void)requestBookmarks {
    DDXMLElement *pubsub = [DDXMLElement elementWithName:@"pubsub" xmlns:@"http://jabber.org/protocol/pubsub"];

    DDXMLElement *items = [DDXMLElement elementWithName:@"items"];
    [items addAttributeWithName:@"node" stringValue:@"storage:bookmarks"];

    [pubsub addChild:items];

    XMPPIQ *iqBookmark = [XMPPIQ iqWithType:@"get" elementID:@"retrievebookmark10" child:pubsub];
    [self.stream sendElement:iqBookmark];
}

It sends the following xml:

<iq type="get" id="retrievebookmark10">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
        <items node="storage:bookmarks"/>
    </pubsub>
</iq>

and I get:

<iq xmlns="jabber:client" from="marge@mydomain.com" to="marge@mydomain.com/41045582821403862604272126" id="retrievebookmark10" type="result">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
        <items node="storage:bookmarks">
            <item id="current">
                <storage xmlns="storage:bookmarks">
                    <conference name="BookmarkName" autojoin="true" jid="testroom@conference.mydomain.com">
                        <nick>Marge</nick>
                    </conference>
                </storage>
            </item>
        </items>
    </pubsub>
</iq>

, . , testroom@conference.mydomain.com , , , . (), .

mod_pubsub :

  mod_pubsub:
   access_createnode: pubsub_createnode
    ## reduces resource comsumption, but XEP incompliant
   ignore_pep_from_offline: true
    ## XEP compliant, but increases resource comsumption
    ## ignore_pep_from_offline: false
   last_item_cache: false
   plugins:
     - "flat"
     - "hometree"
     - "pep" # pep requires mod_caps

, "auto-join = true". ?

+4
1

- - , "".

+2

Source: https://habr.com/ru/post/1546278/


All Articles