Ejemplo n.º 1
0
  @Override
  public boolean isValid(NotificationContext ctx) {
    ExoSocialActivity comment = ctx.value(SocialNotificationUtils.ACTIVITY);
    ExoSocialActivity activity = Utils.getActivityManager().getParentActivity(comment);

    Identity spaceIdentity =
        Utils.getIdentityManager()
            .getOrCreateIdentity(SpaceIdentityProvider.NAME, activity.getStreamOwner(), false);
    // if the space is not null and it's not the default activity of space, then it's valid to make
    // notification
    if (spaceIdentity != null && activity.getPosterId().equals(spaceIdentity.getId())) {
      return false;
    }
    return true;
  }
Ejemplo n.º 2
0
  @Override
  public NotificationInfo makeNotification(NotificationContext ctx) {
    ExoSocialActivity comment = ctx.value(SocialNotificationUtils.ACTIVITY);
    ExoSocialActivity activity = Utils.getActivityManager().getParentActivity(comment);
    // Send notification to all others users who have comment on this activity
    Set<String> receivers = new HashSet<String>();
    Utils.sendToCommeters(receivers, activity.getCommentedIds(), comment.getPosterId());
    Utils.sendToStreamOwner(receivers, activity.getStreamOwner(), comment.getPosterId());
    Utils.sendToActivityPoster(receivers, activity.getPosterId(), comment.getPosterId());

    //
    return NotificationInfo.instance()
        .to(new ArrayList<String>(receivers))
        .with(SocialNotificationUtils.ACTIVITY_ID.getKey(), comment.getId())
        .with(SocialNotificationUtils.POSTER.getKey(), Utils.getUserId(comment.getUserId()))
        .key(getId());
  }