Project: Activity Feed

Problem:

People don't know what is new in their network, most importantly including doc updates, group updates, and comments.
Other apps have a "news feed" where users can see all of the new content in a central location. We can do the same to help show users what is going on with all content that has been synced to their computer.

Solution

We will add a new top-level page in the app that will act as the default page, called "Home Feed"
The feed will include an "infinite" list of items that appear as you scroll down.
Like the documents list, there should be a filter that allows you to toggle between content from trusted and all accounts:
Newer items will appear on the top. All of the timestamps shown are the "publish time" (when the write supposedly happened according to the blob), but the feed is ordered by the "sync time" (when the content appeared on your computer)

Feed Item Types

For all of these feed items, the button in the footer will appear when hovering over the feed item. We may also want an options dropdown in the top right of each feed item, but the options are not clear yet and we can add that another time.

New Conversation

API will provide:
    Comment ID
    Comment Author
    Context Document ID
    Context Document Version

Document Update (Owner)

API will provide:
    Document Owner
    Document Version

Document Variant Update

API will provide:
    Variant Author ID
    Document ID
    Version
    isNewVariant boolean, or maybe the previous version ID of this author variant (which would be empty for new variants)

Comment Reply

API will provide:
    Author ID
    Parent Comment Author ID
    Parent Comment ID
    Comment ID

Group Content Update+Create

The text should say "published ... to" instead of "updated ... in" if the document is new to this group
API Requirements:
    Document ID
    Group ID
    Author ID
    Document Version
    Previous Document Version (unless first publish)
    Pathname

Group Content Removed

API Requirements:
    AccountID
    GroupID
    PathName
    Previous Version

Profile Update+Create

The text should change to "created their profile" if this is a new account.
API Requirements:
    Account ID
    Previous Profile (if existing) - this is useful for showing the old alias at the top of the feed item, to make it clear when users change their name
    Changed Profile Fields

Group Info Update+Create

The text should change to "created" if this is a new group.
API Requirements:
    Group ID
    Previous group info, or version ID for groups.getGroup (undefined if new group) - this is probably not needed, but we need some indication if this is a new group or not
    Changed group info fields

API Requirements

The feed will be added as a single new API endpoint like updates.getFeed or something similar
This is neither a "high-level" nor "low-level" API. Some guiding principles:
    Enough IDs will be provided so that the front end should only have to make one set of follow-up requests for each feed item. This will keep feed items relatively light while reducing waterfall requests for all relevant information that will be displayed
    The feed items will be specific to each entity, as they have different requirements (for example: documents have variants, groups have separate feed items for each item that is changed, etc.)
    In cases where no other APIs are available, content will be inlined into the feed items. For example: there is no API for accessing previous profile information
    One feed item may be provided from the API that will be used across several different UI feed items (for example: group content removal may be presented by the API as a group content update, same with all document updates+creates) as long as enough information is provided for the appropriate UI to be rendered
    UI text is driven by the front-end
Input arguments:
    Page Size (optional)
    Cursor for pagination, provided by the previous request
    TrustedOnly boolean
Output:
    Feed item array. Each item needs:
      Type Enum
      Publish time - when the write (supposedly) happened
      Sync time - when the content was received on this computer
      See type definitions above
    Cursor for pagination, if there are more items.

API Definition

// Request to get feed.
message FeedRequest {
  // Optional. Number of results per page. Default is defined by the server.
  int32 page_size = 1;
  // Optional. Page token to continue listing events from.
  string page_token = 2;
  // Optional. The entity type we want the feed from (hm://*, hm://a/*, 
  // hm://d/AuTBhtNsL9jTxs2X6o3HX1) Default all entities.
  repeated string entity_types = 3;
  // Optional. The list of accounts we want the feed from.
  repeated string account_ids = 4;
}

enum EVENTTTYPE {
  DOCUMENT = 0;
  COMMENT = 1;
  ACCOUNT = 2;
  GROUP = 3;
}

// Document represents metadata and content of a draft or publication.
message Event {
  // The type of the event.
  EVENTTTYPE type = 1;
  // The account ID that originated this event.
  string author = 2;
  // Fully qualified entity ID with version of the entity.
  string eid = 3;
  // When the event was generated.
  google.protobuf.Timestamp generated_ts = 4;
  // When the event was recorded.
  google.protobuf.Timestamp recorded_ts = 5;
  // Token to continue listing events from.
  string next_page_token = 6;
}

// Request to get peer's addresses.
message FeedResponse {
  // The last blob id available for the requested feed
  string blob_id = 1;
  // The last blob id available for the requested feed
  repeated Event events= 2;
  // Token for the next page if there're more results.
  string next_page_token = 3;
}

Scope

1-2 weeks backend
1 week frontend

Rabbit Holes

    There may be "duplicate" entries when a document variant is updated and then immediately published to a group. We should make an effort to de-duplicate these, especially when they appear sequentially in the feed. Not clear if the de-duplication should happen in Go or TS

No Goes

    Feed filters, aside from trusted/all
    Context-specific feeds such as group+document feeds
    Feed items for any "deletion" because that is not really supported yet