In Openfire, how can I get who have subscribed a node? - xmpp

Some client subscribe a node, I want to know how to get the subscriber.
Is there some plugins in the Openfire can do this?

You will need to build the smack version from the repo to get PubSub support. See my blog for details. Once you have build smack, this is how you retrieve the list of subscribers
//Assume pubsub jid is pubsub.myserver
PubSubManager mgr = new PubSubManager(conn, "pubsub.myserver");
//Assume we are dealing with leafnode
LeafNode node = (LeafNode)mgr.getNode("mynode");
List<Subscriptions> subscriptions = node.getSubscriptions();

Related

FCM, How to make all users in group to subscribe to topic

I'm making a social media app like Facebook using Flutter and Firebase.
I'm using Firebase Cloud Messaging to make notification service.
I want to make users who joined community or groups to subscribe their group's topic. Therefore, I can send notification to them by using method which is "subscribeToTopic()". However, I don't know how to make all users in community or groups to subscribe to certain topics.
If you know how to make all users to subscribe to certain topics, please let me know. Thank you!
There is no API to get the current subscribers to a topic, nor is there an API that verbatim subscribes all subscribers to one topic to another topic.
If you already track group membership yourself, you can either let each client subscriber themselves to the additional topic, or you can determine the list of tokens for the group members and then subscribe them to the topic on the server.

How to manage PubSub notifications send while offline in XMPP?

How to get offline message in PubSub? Using the Smack library. after searching I found an answer which looks like this:
// Create a pubsub manager using an existing XMPPConnection
PubSubManager mgr = PubSubManager.getInstanceFor(con);
// Get the node
LeafNode node = mgr.getNode("testNode");
List<? extends Item> items = node.getItems(100);
But node.getItems(100) returns last 100 messages, which can be online and offline too.
1) how to keep track of online and offline message in pubsub using smack?
2) is it possible to get unread message count in pubsub using smack? if yes then how to achieve it?
3) how to know that who(publisher) send this message in a node?
I just went through the documentation of Smack and PubSub from here
and here but didn't find the solutions related to my queries. So can anyone help me to solve this?
1) how to keep track of online and offline message in pubsub using
smack?
I would suggest using the PubSub item ID.
2) is it possible to get unread message count in pubsub using smack?
if yes then how to achieve it?
PubSub nodes don't have a per subscribed unread message count.
If you want to catch-up on all new items since you received the last item from a PubSub node, you'd usually remember the last item's ID and use that to query for all newer items on the PubSub node. Unfortunately there is (currently) no way to query a PubSub node for newer items after a certain ID.
But if you are subscribed to a node, then the service will notify you about new items even if you are offline. And if your server stores those offline messages for you, then you will receive them eventually.
3) how to know that who(publisher) send this message in a node?
Unfortunately there is no reliable way to the the JID of the entity which published an item. This too, could probably be fixed with an extension XEP.

XEP-0060 pubsub auto subscribe node to other users Smack

I am implementing pubsub model to achieve group chat. All things are working well. I am able to create node, other users subscribe the node, publish item by owner or subscriber and item is getting to all subscriber.
Now i have requirement, the owner(User creating node) should be able to subscribe node to roster users and subscribed user start getting item publish.
Is there any way to achieve this?
My node creation code is below:
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setPersistentItems(false);
form.setDeliverPayloads(true);
form.setAccessModel(AccessModel.open);
form.setPublishModel(PublishModel.open);
setSubscribers(form);
LeafNode node = (LeafNode) manager.createNode(nodeName, form);
As document says it is possible to autosubscribe to a node, based on access model which may be roster/presence/open access model.

On presence receiving published item twice ejabberd

I am developing a xmpp client and currently working on "pubsub".
I created a node in pubsub and subscribed two users to it.
But when a subscriber login(show presence) i get the last published item twice.
I am using ejabberd server.
Can anyone help??
Thank you.
Same here,
There seems to be two different queues. With notification_type=normal, messages are stored offline. When receiver becomes online, it receives the message twice:
from offline spool, without headline attribute
from pubsub send loop (as node is still configured with send_last_published_item = on_sub_and_presence)
As stated here when configuring pubsub node with notification_type=normal, it's best to disable send_last_published_item or set it to on_sub only in order to avoid receiving the message twice.

View the messages published to ejabberd xmpp nodes

I have an ejabberd xmpp pubsub server and I'd like to view the messages that have been published to specific nodes. Is there a way to accomplish this within the web admin; if not, how? Thanks much.
I don't know of a way to view pubsub node activity from the web admin, but ejabberd does have a ejabberd-message-archiving module and that may allow it.
You could create a bot or other piece of code that is subscribed to the nodes you want to track and have it create a web viewable archive.