Implementing Notifications in Rails

后端 未结 6 1198
渐次进展
渐次进展 2021-01-30 03:51

In my application, I want to notify a user, when he/she is mentioned in a comment or a post.
The user handle is @user_name, similar to Facebook

6条回答
  •  没有蜡笔的小新
    2021-01-30 04:14

    There is no single recommended approach for this. At an uber level, you may want to look at 'Comet programming', Polling and WebSockets [HTML5] and then choose the right combination. There are a couple of great implementations to manage push notifications in rails. Orbited, Juggernaut, PusherApp, Faye etc. You'll have to dig deep to figure out which of 'em use web-sockets & and fall-back to flash option to handle full support.

    Faye gives a Node.js configuration also, but I am not sure about others.

    Tentatively the steps would look something like:

    1. Save the content - queue it to parser

    2. Parse the content to find out involved users - Use Nokogiri or equivalent.

    3. Comet/Poll it to involved users in current_session as a separate process if you're looking at Twitter like approach.

    4. //Do other things with Post record

    5. Push notifications to involved users and destroy() when they come online later.

      Hope that gives some direction.

提交回复
热议问题