@WebMethod("friend/usersset")
  public boolean setFriends(QueryParams qp, HttpServletRequest req)
      throws UnsupportedEncodingException {
    FriendshipLogic fs = GlobalLogics.getFriendship();

    Context ctx = WutongContext.getContext(qp, true);

    try {
      List<String> l = StringUtils2.splitList(qp.checkGetString("friendIds"), ",", true);
      MessageDelayCombineUtils.sendEmailCombineAndDelayNewFollower(ctx, ctx.getViewerIdString(), l);
    } catch (Exception e) {
      L.error(ctx, e, "delay and combine new follower email error!@@@@");
    }

    String viewerId = ctx.getViewerIdString();
    String friendIds = qp.checkGetString("friendIds");
    String circleId = qp.checkGetString("circleId");
    ConversationLogic c = GlobalLogics.getConversation();
    if (c.getEnabled(ctx, Constants.LOCAL_CIRCLE_OBJECT, circleId) == 1) {
      Set<String> friends = StringUtils2.splitSet(friendIds, ",", true);
      for (String friend : friends) {
        c.createConversationP(
            ctx, Constants.USER_OBJECT, friend, Constants.C_SUBSCRIBE_LOCAL_CIRCLE, viewerId);
      }
    }
    return fs.setFriendsP(
        ctx,
        viewerId,
        friendIds,
        circleId,
        Constants.FRIEND_REASON_MANUALSELECT,
        qp.getBoolean("isadd", true));
  }
Exemplo n.º 2
0
  @Override
  protected String getTitleHtml(Context ctx, Object... args) {
    String apk_id = (String) args[0];
    String userid = (String) args[1];
    String username = (String) args[2];
    String appname = (String) args[3];
    String act = "分享";
    String returnString = "";

    StreamLogic stream = GlobalLogics.getStream();
    RecordSet es_shared_Users = stream.findWhoSharedApp(ctx, apk_id, 200);
    String a = es_shared_Users.joinColumnValues("source", ",");
    List<String> ll = StringUtils2.splitList(a, ",", true);
    if (!ll.contains(userid)) {
      act = "评论";
    }

    if (getSettingKey(ctx).equals(Constants.NTF_MY_APP_LIKE)) {
      // returnString = "您分享(评论)的<stream id="+streamid+">stream</stream>被<user
      // id="+userid+">"+username+"</user> like了";
      // 您"+act+"的
      returnString =
          nameLinks
              + "赞了应用:<a href=\"borqs://application/details?id="
              + apk_id
              + "\">"
              + appname
              + "</a>";
    }
    return returnString;
  }
  @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;
    }
  }
Exemplo n.º 4
0
 @TraceCall
 @Override
 public RecordSet getPages(Context ctx, long[] pageIds) {
   RecordSet pageRecs = new RecordSet();
   if (ArrayUtils.isNotEmpty(pageIds)) {
     String sql =
         new SQLBuilder.Select()
             .select(StringUtils2.splitArray(BASIC_COLS, ",", true))
             .from(pageTable)
             .where(
                 "destroyed_time=0 AND page_id IN (${page_ids})",
                 "page_ids",
                 StringUtils2.join(pageIds, ","))
             .toString();
     SQLExecutor se = getSqlExecutor();
     se.executeRecordSet(sql, pageRecs);
     attachBasicInfo(ctx, pageRecs);
   }
   return pageRecs;
 }
  @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;
  }
  @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;
  }
  protected void process(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    //        L.trace("begin process");
    String url =
        StringUtils.removeStart(
            StringUtils2.joinIgnoreNull(req.getServletPath(), req.getPathInfo()), "/");
    if (processDocument(url, req, resp)) return;

    Invoker invoker = invokers.get(url);
    if (invoker != null) {
      invoker.invoke(req, resp);
    } else {
      resp.setStatus(404); // Not Found
    }
    //        L.trace("end process");
  }
Exemplo n.º 8
0
  @TraceCall
  @Override
  public Record getPageNoThrow(Context ctx, long pageId) {
    String sql =
        new SQLBuilder.Select()
            .select(StringUtils2.splitArray(BASIC_COLS, ",", true))
            .from(pageTable)
            .where("destroyed_time=0 AND page_id = ${v(page_id)}", "page_id", pageId)
            .toString();

    SQLExecutor se = getSqlExecutor();
    Record pageRec = se.executeRecord(sql, null);
    if (MapUtils.isEmpty(pageRec)) return null;

    attachBasicInfo(ctx, pageRec);
    attachDetailInfo(ctx, pageRec);
    return pageRec;
  }
Exemplo n.º 9
0
  @TraceCall
  @Override
  public void destroyPage(Context ctx, long pageId, boolean destroyAssociated) {
    checkUpdatePagePermission(ctx, pageId);
    String sql;

    SQLExecutor se = getSqlExecutor();
    if (destroyAssociated) {
      sql =
          new SQLBuilder.Select()
              .select("associated_id", "free_circle_ids")
              .from(pageTable)
              .where("destroyed_time=0 AND page_id = ${v(page_id)}", "page_id", pageId)
              .toString();
      Record pageRec = se.executeRecord(sql, null);
      if (MapUtils.isNotEmpty(pageRec)) {
        long associatedId = pageRec.getInt("associated_id");
        long[] freeCircleIds =
            StringUtils2.splitIntArray(pageRec.getString("free_circle_ids"), ",");
        long[] allCircleIds =
            associatedId > 0 ? ArrayUtils.add(freeCircleIds, 0, associatedId) : freeCircleIds;
        for (long circleId : allCircleIds) {
          GlobalLogics.getGroup()
              .updateGroupSimple(ctx, circleId, new Record(), Record.of("page_id", 0L));
        }
      }
    }

    sql =
        new SQLBuilder.Update()
            .update(pageTable)
            .value("destroyed_time", DateUtils.nowMillis())
            .where("page_id=${v(page_id)}", "page_id", pageId)
            .toString();

    se.executeUpdate(sql);
  }
 @Override
 protected String getData(Context ctx, Object... args) {
   if (toIds.isEmpty()) return "";
   else return "," + StringUtils2.joinIgnoreBlank(",", toIds) + ",";
 }
Exemplo n.º 11
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);
  }