@Override
  public List<Long> getScope(Context ctx, String senderId, Object... args) {
    List<Long> userIds = new ArrayList<Long>();
    String targetIds = (String) args[0];
    List<Long> targets = StringUtils2.splitIntList(targetIds, ",");

    for (long target : targets) {
      if (!userIds.contains(target)) {
        if ((target >= Constants.PUBLIC_CIRCLE_ID_BEGIN) && (target <= Constants.GROUP_ID_END)) {
          GroupLogic groupImpl = GlobalLogics.getGroup();
          String members = groupImpl.getAllMembers(ctx, target, -1, -1, "");
          List<Long> memberIds = StringUtils2.splitIntList(members, ",");
          userIds.addAll(memberIds);
        } else if (Constants.getUserTypeById(target) == Constants.PAGE_OBJECT) {
          long[] followerIds =
              GlobalLogics.getFriendship()
                  .getFollowerIds(ctx, target, 0, Constants.GROUP_ID_BEGIN, -1, -1);
          userIds.addAll(Arrays.asList(ArrayUtils.toObject(followerIds)));
        } else {
          userIds.add(target);
          toIds.add(target);
        }
      } else {
        if (Constants.getUserTypeById(target) == Constants.USER_OBJECT) {
          toIds.add(target);
        }
      }
    }

    HashSet<Long> set = new HashSet<Long>(userIds);
    userIds = new ArrayList<Long>(set);
    // exclude sender
    if (StringUtils.isNotBlank(senderId)) {
      userIds.remove(Long.parseLong(senderId));
    }

    L.trace(ctx, "Poll Invite Notification Receive userIds: " + userIds);
    return userIds;
  }
예제 #2
0
  private void attachDetailInfo(Context ctx, Record pageRec) {
    long associatedId = pageRec.getInt("associated_id", 0L);
    Record rec = Commons.getUnifiedUser(ctx, associatedId);
    rec.copyColumn(GRP_COL_ID, "circle_id");
    rec.copyColumn(GRP_COL_NAME, "circle_name");
    String freeCircleIds = pageRec.getString("free_circle_ids");
    RecordSet freeCircleRecs;
    if (StringUtils.isBlank(freeCircleIds)) {
      freeCircleRecs = new RecordSet();
    } else {
      freeCircleRecs =
          GlobalLogics.getGroup()
              .getGroups(
                  ctx,
                  Constants.PUBLIC_CIRCLE_ID_BEGIN,
                  Constants.PUBLIC_CIRCLE_ID_END,
                  ctx.getViewerIdString(),
                  freeCircleIds,
                  Constants.GROUP_LIGHT_COLS,
                  false);
    }

    freeCircleRecs.copyColumn(GRP_COL_ID, "circle_id");
    freeCircleRecs.copyColumn(GRP_COL_NAME, "circle_name");
    pageRec.put("associated", rec);
    pageRec.put("free_circles", freeCircleRecs);

    long[] followerIds =
        GlobalLogics.getFriendship()
            .getFollowerIds(ctx, ctx.getViewerId(), 0, Constants.GROUP_ID_BEGIN, 0, 15);
    RecordSet followerUserRecs =
        GlobalLogics.getAccount()
            .getUsers(
                ctx,
                ctx.getViewerIdString(),
                StringUtils2.join(followerIds, ","),
                AccountLogic.USER_LIGHT_COLUMNS,
                true);
    followerUserRecs.retainsCount(5);
    pageRec.put("followers", followerUserRecs);
    int objType = Constants.getUserTypeById(associatedId);
    if (objType == Constants.PUBLIC_CIRCLE_OBJECT) {
      boolean b =
          GlobalLogics.getGroup()
              .hasRight(ctx, associatedId, ctx.getViewerId(), Constants.ROLE_MEMBER);
      pageRec.put("in_associated_circle", b);
    } else {
      pageRec.put("in_associated_circle", false);
    }

    // shared count
    String viewerId = ctx.getViewerIdString();
    String pageId = pageRec.getString("page_id");
    StreamLogic stream = GlobalLogics.getStream();
    Record sharedCount = new Record();
    int sharedText = stream.getSharedCount(ctx, viewerId, pageId, TEXT_POST);
    sharedCount.put("shared_text", sharedText);
    int sharedPhoto = stream.getSharedCount(ctx, viewerId, pageId, PHOTO_POST);
    sharedCount.put("shared_photo", sharedPhoto);
    int sharedBook = stream.getSharedCount(ctx, viewerId, pageId, BOOK_POST);
    sharedCount.put("shared_book", sharedBook);
    int sharedApk = stream.getSharedCount(ctx, viewerId, pageId, APK_POST);
    sharedCount.put("shared_apk", sharedApk);
    int sharedLink = stream.getSharedCount(ctx, viewerId, pageId, LINK_POST);
    sharedCount.put("shared_link", sharedLink);
    int shared_static_file = stream.getSharedCount(ctx, viewerId, pageId, FILE_POST);
    sharedCount.put("shared_static_file", shared_static_file);
    int shared_audio = stream.getSharedCount(ctx, viewerId, pageId, AUDIO_POST);
    sharedCount.put("shared_audio", shared_audio);
    int shared_video = stream.getSharedCount(ctx, viewerId, pageId, VIDEO_POST);
    sharedCount.put("shared_video", shared_video);
    sharedCount.put(
        "shared_poll", GlobalLogics.getPoll().getRelatedPollCount(ctx, viewerId, pageId));

    String eventIds = GlobalLogics.getGroup().getPageEvents(ctx, Long.parseLong(pageId));
    Set<String> set = StringUtils2.splitSet(eventIds, ",", true);
    sharedCount.put("shared_event", set.size());

    pageRec.put("shared_count", sharedCount);
  }