Ruby on Rails with Faye, how to broadcast data to specific subcsriber - ruby-on-rails

i want to build a Ruby on Rails web-apps where using facebook style notification, for the push server i'm using FAYE, is there any solution to broadcast notification for specific client, for case studies in Facebook only your account have notification if somebody send you a message or tag your photo. Thanks

In your client side JavaScript, subscribe to a channel name based on the user (e.g. '/messages/userid_1234') and use that to send private messages from the server.
For security reasons, don't use the actual user ID or even a hash of the username or email, since someone could spoof a subscribe that way. Generate a random GUID on signup for each user and store that with your user's account details.

Related

How to disable chat push for specific user in Group chat of Quickblox

I want to disable push notifications to user who has still not accepted the request for the group.
Note
This answer is valid as per my experience with quickblox framework 2.7 and below. As quickblox is releasing newer version's of framework very frequently you might find a better API for doing it in future. Till then you can make use of this approach.
Answer
I dont think you can disable push notification for a specific user in group using Quickblox api.
When you send a message (QBChat) to a group everyone in the QBChatDialog gets the message including the person who is sending it out him/her self.
There is a Privacy List to prevent the user from receiving message from specific users, but that requires a initiation from user's end. So I dont think that will help you much here. This feature can be used to block a person/group from sending message to user.
Solution
Your best bet would be, not to add the user to group until the user accepts the group request. Implement your own logic to send out the request to each user in group and keep adding the user when he/she accepts the request.
1> Send out QBChat message with a specific custom object with data like group id, group type, group name and all other necessary data, which will differentiate it from other QBChat messages to all the user in group.
2> On receiving this special message, show a UI specific to deal with it, like an alert with "would you like to join the group??" and button accept or deny
3> On tapping accept, make a WS call to your own server and in your server api add the user to specific group for which he has agreed to join.
Because you have already populated QBChat message with object which contains the info about the dialog, you should be able to inform your server easily for which group user has joined.
Once user joined to group he will continue to recieve all the messages in group
EDIT
Here is a detailed answer to your question in comment :)
I was pretty much sure you will ask this question :)
In order to add the occupant id to an existing QBChatDialog group we used the rest api of Quickblox. Remember I told you dont add all the participants to group initially, add them one by one after they accept to join group ?? When user accepts to join the group we call our rest api which in turn invokes the quickblox api and adds the current user id to group :)
You can easily find api for that in API section of quickblox. In case you din find it gimme time till Monday lemme ask my API developer and update u on the same
There is CATACH with this approach.
QB docs clearly says only the owner of the group can add the members to the group. That means just because you have a REST API you cant add the user to group. You will need to have the valid session id of the group owner. You will get the session id when you login, I believe you are very much aware of it :)
Now how on earth will I get the group owner session id ??
Here is the approach we followed. We had foreseen such issues might arise long way before we started the project :)
When user sign up using our app we save his username and password in our server db and generate a random username and password and create a Quickblox account with that usrname and password for the user and we save this quick blox username, quickblox password and quickblox user id for that user :)
So though sign up actually deals with two servers user will always feel like he is dealing with one server and he continue to think he is using his username and password to login to chat.
But in reality when user uses his username and password to login to app in login response we get the quickblox username and quickblox password that server had used to create the account. On receiving it app uses QB framework to login to quickblox account with that username and password :)
This way user is never aware of his quickblox username and password and userid :) Gives us lot of control as well :)
That being said :) now when a user creates a group and sends out a special QBChat message containing custom object, in that custom object along with details of dialog he also sends his quickbloxuserid :)
Now when user who recieves the special QBChat accepts the request, we extract the dialog id (to which he is intending to join) group_owner_id (id of user who created dialog and sent out this special message) and sends it to our rest api along with his own id :)
Once API recieves the group owner id, it fecthes the QB username and password from its db and log's in with that and gets a valid session id and finally adds the user to group with that session id.
Note : Quickblox allows user to login in multiple devices at a time that means it entertains multiple valid session id for user.
Hope I made my point clear :) Happy coding.

How do I associate notification mail reply to user's inbox?

I have an Rails web-application where a user can send message to any other registered user. Once a user sends a message to another user, another user gets a notification on application and also by email in his/her personal email inbox (Like basecamp).
I want to implement this functionality where if a user reply to a message from his/her personal email inbox(say gmail/yahoo), the message becomes available in the application and receiver gets a notification as usual.
As I could understand, we’ll need to associate a unique id and set it as reply-to field in notification mail. Any help in the right way to approach this problem will be very much appreciated.
Thank you
We are already using sendgrid. And sendgrid provides web-hook for emails. Which is quite easy to integrate with a rails application. It also uses mails gem. I'll keep posted if I find anything new on this.
I'm still working on finding out how to associate unique id in reply-to field in email. Any help on this will be much appreciated.
Thanks,
Chandan

Is there any way to send the email without opening the MFMailComposeViewController?

I need to send the email without opening the MFMailCompseViewController. I have searched about this and got some point like use the web service and another one is connect with gmail server through ask the emailID and password from the user.
My email format is fixed i just have to send the email to user whose id will be given by the user without showing any thing else.
Your existing research is accurate - you can connect to some web service to send the e-mail automatically, but you can't automatically create, configure and send using MFMailComposeViewController. The user always gets to see the presented controller and choose whether to do any editing and whether to send or not.
There is no way of sending an email directly from iDevice without showing the MFMailComposeViewController.
If it was possible it would be a great tool for mobile distributed spam bots.
Things to consider: MFMailCompseViewController is an interface for the user to compose an email.
If you want to use it, you have to hand over control to it. Apple does not expose the underlying functionality to you: it has to go through this view controller.
If you don't want the user to be aware that you are sending emails on their behalf (I assume it is on their behalf or you wouldn't need the composer view) you are probable doing things a little wrong; why would you want to send an unsolicited email?
If you want to report information from the device, implement a web service and send it to that. Email is meant for correspondence; don't hijack an account.
If you still need an email, have the web service create it

restrict sending mail from gmail/yahoo in ipad

I am designing an application for a society.
In this application, there is a feature to send the contents of the particular page via mail by clicking of a button. There is no custom mail app designed. The feature uses iPad's native mail app to send the mail.
I want to restrict the user to send the mail only from the society's domain registered mail account and not from his/her personal gmail/yahoo/msn id.
How do I put this restriction from my app?
Thanks in advance
I suggest you send the email from your server, as you won't (and shouldn't) be able to control the user's email app. In other words, you allow the user to enter one or more email addresses into your app and then put the contents of the page into an email that you send from your email server to the specified addresses.

Rails, SendGrid - Forwarding mailer-daemon emails to user

I have an application that allows users to send an invitation to a friend. Emails are being sent out using SendGrid. I am wondering if it's possible to forward the mailer-daemon emails back to the user in an event they type in an email address that doesn't exist.
So for example a user enters in the email 'thisisnotreal#fakedomain1234.com' to send the invitation. I want to be able to notify the user that the email they have entered doesn't exist. Usually when you just send an email from an email client the server lets you know right away that the email is not able to be delivered. I am wondering if it's possible to do this as well through SendGrid.
Take a look at the event notification section of the SendGrid API. You can add a page to your application that accepts POST requests from SendGrid, and then you'll get event notifications in real-time.
When a bounce event is posted to that listener from SendGrid, you could then lookup the user that needs to be notified via the recipient email. If you don't have this relationship available in your local store, you could pass a unique argument to SendGrid at send time that contains information you can use for the lookup - unique arg information is included with event notifications. Then it's just a matter of taking the appropriate action required to notify your user - either with an email or via a notice on your website or a text message or whatever is best for your application.
This maintains asynchronous communication. You'll be alerted when something goes wrong without having to add blocking code, and you can send your users a nice branded message (using SendGrid, of course) rather than just forwarding a mailer-daemon response .

Resources