Project

General

Profile

PubSub: Owner affiliation

Mohammed Azhar
Added almost 3 years ago

Hi

I was wondering how can i give every subscriber to a node the owner affiliation so that he can subscribe others...

Here is the use case:

I am planning to create a group chat feature using PubSub. A user will create a group(node) and add other users as members, these subscribed user can also subscribe other users to this node.

Any help is appreciated

Thank you.


Replies (6)

Avatar?id=6098&size=32x32

Added by Bartosz Małkowski TigaseTeam almost 3 years ago

Only owner is able to modify subscribers list.

You need to modify code of PubSub component to allow this action for other affiliations

Added by Mohammed Azhar almost 3 years ago

Thanks for the reply.

Could you point me tutorials or docs where this is explained.

(1)

Added by Wojciech Kapcia TigaseTeam almost 3 years ago

The workflow itself is described in the specification, namely PubSub XEP. The actual implementation in Tigase is done in one of the PubSub modules, namely SubscribeNodeModule.java

(1)

Added by Mohammed Azhar almost 3 years ago

Thanks again...

I have created a plugin which intercepts the subscription packet and makes the subscribed user the owner using the TigPubSubSetNodeAffiliation stored procedure. This gives the subscribed user owner affiliation but when he try to subscribe others it gives an error...

However if i restart the server then he can subscribe others..

Is there something a we can do to make this work without restarting the server?

Thank you

Added by Wojciech Kapcia TigaseTeam almost 3 years ago

Mohammed Azhar wrote:

I have created a plugin

A plugin? In session manager?

which intercepts the subscription packet and makes the subscribed user the owner using the TigPubSubSetNodeAffiliation stored procedure. This gives the subscribed user owner affiliation but when he try to subscribe others it gives an error...

This is a very wrong approach. Tigase PubSub component reads data from database only after restart (and sometimes when there is a need to refresh data, but it's rare). Therefore you should avoid modifying data directly in the repository (even with stored procedures)!!!

However if i restart the server then he can subscribe others..

This is in line with how it should work

Is there something a we can do to make this work without restarting the server?

As suggested above - you should modify SubscribeNodeModule and utilize available PubSub API directly.

(1)

Added by Mohammed Azhar almost 3 years ago

Thanks for the reply.

I was able to solve the problem by pushing a give ownership packet to the packet queue of the postProcess method of the plugin after a subscription request is made.

I really did not want to modify the server code because then we might need to do manually change it in the future versions as well but we needed a more automated install procedure.

Anyway now i am able to make every subscriber the owner of the node and they are able to subscribe others as well.

    (1-6/6)