add method

Future<Reaction> add(
  1. String kind,
  2. String activityId, {
  3. String? userId,
  4. Map<String, Object>? data,
  5. List<FeedId>? targetFeeds,
})

Add reaction

Parameters: kind : kind of reaction activityId : an ActivityID data : extra data related to target feeds targetFeeds : an array of feeds to which to send an activity with the reaction

Examples:

  • Add a like reaction to the activity with id activityId
final like = await client.reactions.add('like', activity.id, 'john-doe');
  • Add a comment reaction to the activity with id activityId
final comment = await client.reactions.add(
  'comment',
  activity.id,
 userId: 'john-doe',
  data: {'text': 'awesome post!'},
);

API docs: adding-reactions

Implementation

Future<Reaction> add(
  String kind,
  String activityId, {
  String? userId,
  Map<String, Object>? data,
  List<FeedId>? targetFeeds,
}) {
  final reaction = Reaction(
    kind: kind,
    activityId: activityId,
    userId: userId,
    data: data,
    targetFeeds: targetFeeds,
  );
  final token =
      userToken ?? TokenHelper.buildReactionToken(secret!, TokenAction.write);
  return _reactions.add(token, reaction);
}