Wrong presence shown for unsbscribe user in ejabberd - xmpp

I have below roster list of admin:
Jabber ID Subscription Pending
user1#manish-lenovo-g510 to in
if user1 is not logged in
connection.addHandler(Gab.on_presence, null, "presence");
shows subscribe but if user1 log in the above handler show online presence and i am able to do chat. So if user1 is logged in i am not able to know that he is subscribed or not as it show online. SO how can i avoid chat without subscription ?

Related

Conversejs groupchat subscriptions (ejabberd)

I have been struggling to configure a group chat using conversejs and ejabberd. From the documentation I've stumbled across, it seems like it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.
For example: I would like to be able to simply close the group chat on my conversejs client, but still get notifications from that group chat.
This is a fresh ejabberd 21.04 and conversejs 7.0.6 install (using websockets).
What I tried to do was create a room through the conversejs client, and then add a subscription through the ejabberd cli:
ejabberdctl subscribe_room user#my.example.com/muc user test_room#conference.my.example.com urn:xmpp:mucsub:nodes:messages
One of the things I'm most confused by is the field in the configuration panel of a group chat that is titled "XMPP URI of Associated Publish-Subscribe Node." I have no clue how to format this, but have found a few clues online... What I have tried is a number of different configurations of something like:
xmpp:my.example.com?;node=messages
but I'm really just grasping at straws here.
If anyone can help me figure out what I'm doing wrong with this URI, or can show me a working example of this, that would be amazing. If what I'm trying to do simply isn't possible with XMPP, please let me know as well.
Thanks!
it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.
Exactly.
ejabberdctl create_room room1 conf.localhost localhost
ejabberdctl change_room_option room1 conf.localhost persistent true
ejabberdctl change_room_option room1 conf.localhost allow_subscription true
ejabberdctl subscribe_room user1#localhost User1 room1#conf.localhost urn:xmpp:mucsub:nodes:messages
Now I'll use the send_message API call to send a message to the room. This requires the sender to be online, so for this example register and login to admin#localhost. And of course, login to user1#localhost to receive the notification from the room. Those clients do not need to join the room.
ejabberdctl send_message groupchat admin#localhost room1#conf.localhost Sub Body

Already have "pages_messaging" permission, but once the subscription endpoint is called. It says I need to request "pages_messaging"

To activate bot to page, pages_messaging permission is required as stated in documentation. The permission has been submitted and approved. It's working fine under development mode. But once set to live mode and tried to subscribe chat bot to another page, it throws the following error.
(#200) To subscribe to the messages field, one of these permissions is needed: pages_messaging. To subscribe to the messaging_postbacks field, one of these permissions is needed: pages_messaging. To subscribe to the messaging_optins field, one of these permissions is needed: pages_messaging. To subscribe to the messaging_referrals field, one of these permissions is needed: pages_messaging. To subscribe to the messaging_policy_enforcement field, one of these permissions is needed: pages_messaging"
Endpoint ===> https://graph.facebook.com/v4.0/${page_id}/subscribed_apps?access_token=${access_token}&appsecret_proof=${appsecret_proof}&subscribed_fields=messages,messaging_postbacks,messaging_optins,messaging_referrals,messaging_policy_enforcement

Start conversation without user interaction in Facebook Messenger

Is it possible to send a message to a user without the user interacting with the bot first?
I'm using the following guide to retrieve psids from users that have already connected their profile to an app that I own.
https://developers.facebook.com/docs/messenger-platform/connecting-accounts.
For users that have at least one interaction with a page that I also own, I'm able to get their id. For all other users the endpoint returns an empty array.
Im aware of customer matching but is that the only way to achieve this?
You can't send a message by bot before the user initializes the conversation.
Facebook Messanger Bot permits a standard messages, with a 24-hour interval
to reply to a message initiated by a user. In Some specific cases, Facebook permits to send a message after this time.
A message are triggerd when the user either sends a message to a company or clicks a call button for action in Messenger, or when the user requests a message from a company through a plugin, such as send to Messenger.
Check out the policies here : https://developers.facebook.com/docs/messenger-platform/policy-overview
You are correct, customer matching is your only option for this.
Just learned this today, if you have a user's phone number, you can message them unprompted. You also need the pages_messaging_phone_number permission, which you can only get by paying the $99 customer matching fee.
Check the docs on sending to phone numbers here. Customer matching docs here

How can i login ejabberd anonymously with given name?

I'm building a chat app, and i wanna manage my users in my own database. how can i use ejabberd to transmit my users's messages , who does not registered on ejabberd?
if it possible to login all the users anonymous, and still store their off-line messages?
if it not possible, what should i do ?

How can i handle online status in pjsip in iphone

We are developing an application in that we are providing VOIP feature using pjsip.We done every thing well upto registration process and adding friends .But We are facing some problems regarding to friends online status.
I explain my problem indetail..For suppose 'user1' is login and has one friend 'user2' then user2 is offline it is correct(b'coz user2 still not login) when user2 login and has one friend user1 then user1 is online it is correct(b'coz user1 already logedin) but user2 is not shown online in user1's friends
can any one solve my problem ,i stuck here for last 3 days. thanks inadvance
Here's a simple exercise using PJSUA app which should help you solve your problem
Start PJSUA app (on default port). Call this pjsua-app1.
Start another instance of PJSUA on another port. Call this pjsua-app2.
To pjsua-app1 add account user1#a.b.c.d:p, to pjsua-app2 add account user2#a.b.c.d:q
To pjsua-app1 add buddy user2 and to pjsua-app2 add buddy user1
On both apps subscribe presence.
You should see them online if they are logged in