Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add option to enrich reaction object withOwnReactions, withReactionCounts, etc. #592

Open
SahidMiller opened this issue Jan 12, 2024 · 0 comments

Comments

@SahidMiller
Copy link

SahidMiller commented Jan 12, 2024

Please add the option to enrich a reaction's activity object with the activity's reactions so clients can display the original activity's reaction counts and current user's own reactions. This is necessary to implement common features in popular social media platforms like Twitter, such as "reposts" (displaying the original activity's reaction counts) and similar features.

Currently, the code below allows reposting but does not allow client.feed('user_likes', userId).get({}) to retrieve the original activity's reaction counts or the current user's own reactions to the original activity. Enrichment only returns the original activity's basic information (via object) without it's reactions.

await client.reactions.add('like', activityId, {}, {
    userId,
    targetFeeds: ['user_likes:' + userId],
  }
)

client.feed('user_likes', userId).get({
  user_id: currentUserId || undefined,
  id_lte: cursor2?.fromId,
  limit: 20,
  enrich: true,
  withOwnReactions: true,
  withReactionCounts: true,
  withOwnChildren: true,
})

/**
Returns: 
{
   foreign_id: 'reaction:...',
   id: '...',
   actor: {
     //reaction's actor
   },
   object: {
    //original activity info
    actor: '...',
    foreign_id: '...',
    id: '...',
    object: '...',
    origin: null,
    target: '',
    time: '...',
    verb: 'post'
   },
   origin: null,
   own_reactions: {},
   reaction: {
    //reaction's info
    created_at: '...',
    updated_at: '...',
    id: '...',
    user_id: '...',
    kind: 'like',
    activity_id: '...',
    data: {},
    target_feeds: [..],
    parent: '',
    latest_children: {},
    children_counts: {}
   },
  //child reaction count of current reaction
  reaction_counts: {},
  verb: 'like'
}
**/

The code below also allows for a reposting type feature with the original's reactions but does not maintain the order of when the activity was added to the additional feed. Rather, it orders based on the activity's original create date. (ie. liking post2 and then post1, will return post1 before post2 when fetched).

client.feed('user', authorId).updateActivityToTargets(postId, createdAt.toISOString(), undefined, [`user_likes:${userId}`])

Please add the option to enrich reactions with activity objects with that activity objects reactions such as with the following options:

client.feed('user', id).get({
  user_id: currentUserId || undefined,
  id_lte: cursor2?.fromId,
  limit: 20,
  enrich: true,

  //EXISTING: For current activity
  withOwnReactions: true,
  withReactionCounts: true,
  withOwnChildren: true,

  //NEW: for nested activity
  withActivityObjectReactions: true,
  withOwnActivityObjectReactions: true
})

/**
Returns: same as previous code snippet but adding the following:
{
  object: {
   //NEW: for nested activity (original activity reacted to)
   reaction_counts: {},
   own_reactions: {}
  }
}
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant