In this blog post we will continue to talk about activity stream, cover aggregation and delivery of content and describe architecture of activity stream in Open Social.
How to create an activity stream?
To begin let us recall that any activity stream is generated from user’s activities. The task of forming a stream actually means delivering content from the author to other interested users. The stream usually consists of completely different content: posts, topics, events, etc. On top of this we have a comments, likes, joining to groups or events and other things. Therefore, the main problems faced by social network developers are:
- Aggregation of all content from users and creating activities.
- Delivery of aggregated content to different destinations (streams).
Both these tasks are mainly done in what we call our ‘Activity Factory’, you can see in the picture below. It receives entities of different types and convert all of them to Activity entities, which are displayed on different channels.
Architecture of activity stream in Open Social
First it is good to understand the main concepts of a Message and Activity entity and how they are related to each other.
The Message entity is created when an event is triggered (e.g. a post is created). It’s being build from a Message template that contains tokenized text. The Message does not contain recipients (list of users), who need to receive this notification neither the final output that is displayed from the tokenized output. We use the Activity entity to store this information.
- Activity Logger: Used to log activities based on the message module. Provides message queue creator and activity logger factory.
- Activity Creator: Core activity module. Provides Activity entity, activity factory, activity queue workers and base classes for activity plugins.
- Activity Viewer: Used to display activities with support for views. Provides views filters and arguments. Activity Basics: Provides activity plugins and basic implementation of activities in Open Social.
- Activity Send: Used to store and manage external notifications. Provides base class for ActivitySend plugins and activity send queue workers.
- Activity Send Email: Used to send activity notifications by email.
- Social Activity: Feature that provides message templates, activity stream views and blocks.
Our Activity stream is built to be pluggable in many ways. The plugin system is based on following types:
- Activity Action: Plugin that handles the creation of a Message. Currently we have CreateActivityAction, probably later we will have JoinActivityAction, UpdateActivityAction etc.
- Activity Context: Responsible to determine which entities are eligible to be used and to which recipients an Activity should be sent. We have following contexts at the moment: Community, Group, My Group, Profile, Owner.
- Activity Destination: The channels used to display the Activity. Currently we have 4 activity streams: Home, Explore, Group, Profile and two destinations for notifications: Notification center, and Email notification. This plugin should be used when we extend the outputs for other channels such as push notifications or slack.
- Activity Entity Condition: This type of plugins adds more flexibility for activities. For example we have special condition for comments and check whether comment is a reply to other comment or not.
- Activity Send: Responsible to create queue items for sending external notifications. Currently is used for sending emails.
All these plugins are related to message template entity and can be configured by administrator. See example in picture below.
At the time of writing this article we have 14 message templates, which are displayed in 6 destinations.
The roadmap of the activity stream in Open Social
We are improving and expanding functionality of activity stream each sprint. Here are the most important new features in our roadmap:
- Notifications center improvements
- Personalized homepage
- Aggregation of email notifications
- Upload photos to post or comment
- Mention feature
- Like feature
- Follow content
- Follow friends
Contributing to Open Social or Drupal
So how to go about contributing to Open Social and/or Drupal in general? For Open Social a good starting point is the Open Social Documentation Guide. If you want a starting point for helping Drupal to grow you can find many different ways on the ‘ways to get involved’-page on Drupal.org.