コード例 #1
0
  @Override
  public List<Long> getScope(Context ctx, String senderId, RecordSet recs, Object... args) {
    List<Long> userIds = new ArrayList<Long>();

    List<String> reasons = new ArrayList<String>();
    reasons.add(String.valueOf(Constants.C_STREAM_TO));
    reasons.add(String.valueOf(Constants.C_STREAM_ADDTO));
    ConversationLogic conversation = GlobalLogics.getConversation();
    RecordSet conversation_users =
        conversation.getConversation(
            ctx, Constants.POST_OBJECT, (String) args[0], reasons, 0, 0, 100);
    for (Record r : conversation_users) {
      long userId = Long.parseLong(r.getString("from_"));
      if (!userIds.contains(userId)) {
        if ((userId >= Constants.PUBLIC_CIRCLE_ID_BEGIN) && (userId <= Constants.GROUP_ID_END)) {
          groups.add(userId);
          GroupLogic groupImpl = GlobalLogics.getGroup();
          String members = groupImpl.getAllMembers(ctx, userId, -1, -1, "");
          List<Long> memberIds = StringUtils2.splitIntList(members, ",");
          userIds.addAll(memberIds);

          if (recs == null) {
            recs = new RecordSet();
          }
          RecordSet notifRecs = groupImpl.getMembersNotification(ctx, userId, members);
          recs.addAll(notifRecs);

          for (Record notifRec : notifRecs) {
            String memberId = notifRec.getString("member");
            long recvNotif = notifRec.getInt("recv_notif", 0);
            if (recvNotif == 2) {
              userIds.remove(Long.parseLong(memberId));
            }
          }
        } else userIds.add(userId);
      }
    }
    // =========================new send to ,from conversation end ====================

    // exclude sender
    if (StringUtils.isNotBlank(senderId)) {
      userIds.remove(Long.parseLong(senderId));
    }
    try {
      IgnoreLogic ignore = GlobalLogics.getIgnore();
      userIds = ignore.formatIgnoreUserListP(ctx, userIds, "", "");
    } catch (Exception e) {
    }

    return userIds;
  }
コード例 #2
0
  @WebMethod("circle/show")
  public RecordSet showCircles(QueryParams qp) {
    FriendshipLogic fs = GlobalLogics.getFriendship();
    GroupLogic group = GlobalLogics.getGroup();

    Context ctx = WutongContext.getContext(qp, false);
    String userId = qp.getString("user", ctx.getViewerIdString());

    boolean withPublicCircles = qp.getBoolean("with_public_circles", false);
    if (!withPublicCircles) {
      RecordSet recs =
          fs.getCircles(
              ctx, userId, qp.getString("circles", ""), qp.getBoolean("with_users", false));
      attachSubscribe(ctx, recs);
      return recs;
    } else {
      String circleIds = qp.getString("circles", "");
      boolean withMembers = qp.getBoolean("with_users", false);
      List<String> circles = StringUtils2.splitList(circleIds, ",", true);
      List<String> groups = group.getGroupIdsFromMentions(ctx, circles);
      circles.removeAll(groups);
      RecordSet recs =
          fs.getCirclesP(ctx, userId, StringUtils2.joinIgnoreBlank(",", circles), withMembers);
      RecordSet recs0 =
          group.getGroups(
              ctx,
              PUBLIC_CIRCLE_ID_BEGIN,
              PUBLIC_CIRCLE_ID_END,
              ctx.getViewerIdString(),
              StringUtils2.joinIgnoreBlank(",", groups),
              GROUP_LIGHT_COLS + ",circle_ids,formal,subtype,parent_id",
              withMembers);
      recs0.renameColumn(GRP_COL_ID, "circle_id");
      recs0.renameColumn(GRP_COL_NAME, "circle_name");
      for (Record rec : recs) rec.put("type", CIRCLE_TYPE_LOCAL);
      for (Record rec : recs0) rec.put("type", CIRCLE_TYPE_PUBLIC);
      recs.addAll(recs0);

      attachSubscribe(ctx, recs);
      return recs;
    }
  }
コード例 #3
0
  @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;
  }