Auto subscribe roster presence request in ejabberd by server - erlang

I am new in ejabberd world. Currently i am using ejabberd server for instant messaging.
My usecase
When client send roster subscription to the server then server automatically approve subscription requests on the contact's behalf if exist.
Ejabberd does not have this feature or option to automatically approve subscription requests
for this i am using these hooks
roster_in_subscription
roster_out_subscription
My problem is how to accept subscription request after getting request.
Is there any alternate solution?
plz help

This is what is mentioned in RFC 3921 present here in presence section.
Visit section 5.1.6. Responsibility to auto-accept presence requests lies with the client.
I wrote the following code in smack to auto-accept presence requests.
Roster roster = Roster.getInstanceFor(connection);
roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);

Related

How to auto-approve the presence requests in Ejabberd server without approving by contacts

I am using Ejabberd server from the source code in Linux. My situation is,if I need presence of someone then I need to add him/her in my roster and approved his/her presence request. Since I am interested in presence of a single contact at a time so it is useless for me to add lots of contacts in roster with presence approved. So I want some mechanism by which I send the presence request to someone and this request will be approved instantly by the server irrespective of the other contacts available online to approve the request or not. I am using Ejabberd 17.11 version and backend SQL for storing most of the data on the Linux Mint.
In short, Ejabberd server should automatically approve all the presence request instead of forwarding the request to the contact and wait for the approval.
As per RFC3921 https://xmpp.org/rfcs/rfc3921.html#presence, A user's server MUST NOT automatically approve subscription requests on the user's behalf. All subscription requests MUST be directed to the user's client, specifically to one or more available resources associated with the user.
I would suggest to move auto approval functionality to client side.
Hi I'm using an enhanced ejabberd named MongooseIM. I have written some articles about ejabberd on TechTalk in Chinese.
If you want to auto approval the presence, you must modify ejabberd_c2s:process_outgoing_stanzaand mod_roster:process_subscription_transaction to break the origin approval flow in MongooseIM.
I think you can do the same thing in ejabberd.

how to check Twilio Web Client online from twilio php REST

The scenario is - A twilio web client 'Mr TWC' and A customer 'Mr 123'.
Now I need to respond 'Mr 123' based on 'Mr TWC' in online on a web browser OR offline/not on a web browser.
Thanks In Advance
Twilio developer evangelist here.
I'm afraid there's no way to check the status of Twilio Client users via the REST API.
There used to be presence events available on the Client, but this was deprecated in version 1.3. So, I recommend you keep track of whether your users are online yourself. You could do so by maintaining a list of online users in something like redis on your server. Every time a user successfully authenticates and starts listening for incoming calls with Client, send an Ajax request to your backend to add their username to the list. Then, when they go offline, or close the browser you can send another request to remove their name from the list.
Let me know if that helps at all.

How to save twilio ip message to a database?

I'm discovering twilio ip messaging and i want to make a simple basic chat application. It's not so difficult but i want every sent messages to be stored in a database.
I was seeking some solutions into the twilio user interface but no such things to help me to solve this issue.
I am using amazon dynamodb. How could i process it so that each time I relogin to the chat i could see messages from the last session ?
Twilio evangelist here.
I think you are looking for the onMessageSend webhook:
https://www.twilio.com/docs/api/ip-messaging/webhooks
You can configure for IP Messaging Service instance with a URL for this webhook either in the account portal or via the rest API. Twilio will request that URL whenever a client sends a message to the channel. The webhook will include the sender id, channel id and message which you can save to your database.
Hope that helps.

Sinch authencation using own backend

I am able to generate the token for users and successfully start the SinchClient by following this tutorial. Now, next step is to send and receive messages. Now, how do I recognize users? Since I am using authentication token to start the SinchCleint and not a particular username when starting a SincClient, then how can I send messages to a particular user?
As you recognize Sinch doesn't have the info about your users, you only start the client with a unique token. Sinch is built on the assumption that you have a user database and social network of you own, and the sinch client "address" to send messages to is something you keep track of. Does that make sense?

Amazon SNS Mobile Push - how to bulk subscribe endpoints to a topic?

I am trying to move my existing iOS push notification infrastructure over to amazon SNS mobile push.
I exported all my tokens from my local db into an SNS application (using CSV). Now I want to send push notification to all my 10,000 users. I think the only way is to create a topic and subscribe all the users to that topic then publish message to that topic.
Is there any easy way to subscribe all the 10,000 users who I have imported into the system to a topic?
Thanks for any help!
It sounds like you have created the Amazon SNS Platform Application and imported your tokens as Amazon SNS Platform Endpoints.
What kind of notification are you sending?
If you send a custom message to each user, use Direct
Addressing. With this approach, you
Publish to each EndpointARN.
If you send the same message to all users, use topics. You need to subscribe your endpoints to a topic. When you are ready to send, Publish to the TopicARN. Amazon SNS will handle delivery to all endpoints subscribed to that topic. Amazon SNS currently does not provide a bulk subscribe API, so you will have to invoke Subscribe once per EndpointARN.
Full disclosure: I work for AWS on Amazon SNS.
Unfortunately there is no way so far... see Bulk push endpoints subscription to a topic on AWS Discussion Forum.
Hi there langelvicente,
Thanks for this feature request. I've passed this back through to the SNS Service Team for review.
Best regards,
Phil P
This is now possible with subscribing mobile endpoints to topics. The default subscriber limit was increased.
Q: Are there limits to the number of topics or number of subscribers
per topic?
By default, SNS offers 10 million subscriptions per topic, and 3,000
topics per account. To request a higher limit, please contact us at
at http://aws.amazon.com/support
http://aws.amazon.com/sns/faqs/?nc2=h_ls
If you have an application full of endpoints which you want to bulk subscribe to a SNS topic you can do so from the AWS SNS dashboard by:
Going to that application in SNS
Waiting until the 'total items' count at the bottom has completed its count (ie all items are listed)
Checking the select all check mark above the list of endpoints (screenshot attached)
Tap on platform action > subscribe endpoints to topic
Enter your topic ARN and click create subscription
The process will begin and it will stall your web browser but let it be as it takes time and if you want to see the subscriptions to the topic increasing you can use the AWS CLI with :
aws sns get-topic-attributes --topic-arn "[YOUR TOPIC ARN]"
note the "SubscriptionsConfirmed" value
Yes, but caveat: they each must accept your effort to enroll them into push messaging. That means that for each token in your database, each individual must consent to receiving future messages from you (via SMS and email, that is).
Each address (tel #, email) becomes an endpoint, and you can use SNS to create a topic, then subscribe each endpoint. After a confirmation email is sent to each endpoint (person on your list), they must confirm, in order to begin receiving your stream of messages via text or email.
Unfortunately, this confirmation/consent event is dicey, and must be handled correctly. Your ARN's title must be succinct (7 letter via SMS, no subject line allowed). Hence, you must contact them via SMS using a name they will recognize (the SMS message will arrive via short code, 304-something), and can be refused and/or blocked.
Not trivial! Best to investigate using push messages via mobile app. This will avoid the coveted SMS space, but you might consider putting out a blast to email and/or SMS, in order to get them using your mobile app. Apparently, given the immediacy of SMS, folks will be reading your first confirmation within 20 seconds. This could be a good thing, if they confirm, then accept your future messages.
Am doing this right now, and am preparing to be recognized by name using my initial blast -- apps that create anonymous SMS will be banned through iTunes!

Resources