Updated many of the sections and added E-mail Notification and Subscription sections.
diff --git a/NewsfeedModule.wiki b/NewsfeedModule.wiki index 1e4330e..80590b0 100644 --- a/NewsfeedModule.wiki +++ b/NewsfeedModule.wiki
@@ -11,7 +11,7 @@ Because of the relatively simple nature of the initial project, some of the post-midterm development will include an auxiliary open source pubsub component meant to be deployed separately, and act as a hub allowing Melange instances to host chat, Google Wave updates, and other real-time activity. -= Model = += NewsFeed Model = An individual FeedItem entity is created for each news feed update. A garbage collection task will delete old feed items, so they don't take over the datastore. @@ -19,7 +19,7 @@ * *sender* (db.Key) - The sender is the entity that was updated - * *receiver* (db.Key) - The receiver is one of the entities whose news feed is being updated. + * *receivers* (db.Key) - A list of entities whose news feed is being updated. * *update_type* (created, deleted, modified) @@ -28,25 +28,10 @@ A FeedItem is created for each sender-receiver pair. For instance, if a document is created and saved, it is the sender while its associated project and program and user could all be receivers. -Update (July 10): - -I've created a sharded counter of feed items for an entity (receiving entity). - -{{{ -class FeedItemCount(db.Model): - """Shared Counter of Feed Items for an Entity - """ - entity = db.StringProperty() - count = db.IntegerProperty(default=0) -}}} - -Is this something that would be useful for Statistics or other features? - - = Logic = -Newsfeed logic consists of two methods: +Newsfeed logic consists of two public methods: * *addToFeed* takes a sender entity, a list of receiver entities, an update type, and an optional payload (like a text preview of a document). It adds all the receivers to a FeedItem with the specified payload: {{{ @@ -73,10 +58,10 @@ = Views = -The newsfeed view is very simple at the moment, although the placement of the newsfeed template component in multiple templates seems to violate DRY. The newsfeed template itself is simply a table modeled after the blog template that lists each news feed update, which is added to the context dict through the retrieveFeed method. +The newsfeed template itself is simply a table modeled after the blog template that lists each news feed update, which is added to the context dict through the retrieveFeed method. -= Subscription = += Subscribe via RSS = I've added a new url_path 'subscribe', so that a URL for requesting an ATOM feed would look like this: @@ -102,6 +87,20 @@ The 'subscribe' path will also be the interface for any PubSub interactions, but those will only be activated on POST requests with a callback URL, otherwise the ATOM feed will be returned as normal. + +== E-mail Notification Task == + +When a feed item is created, it schedules a handler to send out e-mail notification. This handler calls the sendFeedItemEmailNotifications method that fetches a list of users who are subscribed to the sender entity and e-mails them. + +(This results in an OverQuota Error for more than a few people, and since it's in a task, it refreshes and starts e-mailing people again! The solution is to put the mail_dispatcher sendMessage method into a task, so all e-mails are sent via tasks and don't risk mass-spamming when a request fails.) + + +== User Subscriptions == + + +The subscriptions model contains a relational index entity for the user, containing a list of entity keys that the user is subscribed to. From their edit_profile page, the user can set a global preference for whether they are accepting e-mail notifications, and the user can also configure individual entity preferences from those pages using the subscribe-by-star UI pattern. + + == PubSubHubbub Support == <wiki:video url="http://www.youtube.com/watch?v=ewQBgbysSOQ"/> @@ -112,66 +111,6 @@ -= TODO Items = - - - * Feed Items should be created through Task API. - -This is an example task scheduling method posted on the TaskQueueAPI wiki page: - -{{{ -def emailAllTaskStarter(self, request, access_type, page_name=None, - params=None, **kwargs): - - logic = params['logic'] - link_id = kwargs['link_id'] - scope_path = kwargs['scope_path'] - - fields = { - 'url_name': params['url_name'], - 'scope_path': scope_path, - 'link_id': link_id - } - - url = '/%(url_name)s/email_all_task/%(scope_path)s/%(link_id)s' % fields - - program = logic.getFromKeyFields(kwargs) - scope_path = program.scope_path + '/' + program.link_id - - context = { - 'filter': simplejson.dumps({ 'scope_path': scope_path }), - 'logic': 'soc.logic.models.student' - } - - task = tasks.startTask(url=url, context=context) - - return self.public(request, access_type, page_name=page_name, params=params, **kwargs) -}}} - - -The task is given a URL as an argument, meaning that we need a RESTful way of expressing our arguments. This presents a challenge for addFeedItem, because it requires a sender entity and a list of receiver entities. - -So far, my implementation normally uses the scope and link_id for the sender (matching the typical View pattern) and then adds a list of receiver keys in a GET request. (This is not great from a security perspective). - - * A better way or UI to program news feed rules. - - There are two ways that This can either be done from the publishing end, such as the org admin deciding top-down that only featured documents will be added to the news feed, or it can be done from the subscription end and unique feeds could be generated. This unique feed would require an addition model and datastore hits. - - - - * E-mail notifications (news feed subscription via e-mail) - - This should be fairly straightforward to accomplish using the mail API. - - - - * Limitations to Feed Item Senders - - Right now, News Feed logic only applies to entities subclassed from the Work model. This is just so they can properly formatted in the news feed template. Investigate and implement to make the template more generic. - - * Statistics Module Integration - - If there is time, integrating news feed functionality with Mario Ferraro and Daniel Hans statistics module could provide additional value on both ends.