@WebMethod("friend/circlesset")
  public NoResponse setCircles(QueryParams qp, HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    FriendshipLogic fs = GlobalLogics.getFriendship();

    Context ctx = WutongContext.getContext(qp, true);
    String viewerId = ctx.getViewerIdString();
    String friendId = qp.checkGetString("friendId");
    String circleIds = qp.checkGetString("circleIds");
    ConversationLogic c = GlobalLogics.getConversation();
    Map<String, Integer> map = c.getEnabledByTargetIds(ctx, circleIds);
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      String circleId = entry.getKey();
      int enabled = entry.getValue();
      if (enabled == 1) {
        c.createConversationP(
            ctx, Constants.USER_OBJECT, friendId, Constants.C_SUBSCRIBE_LOCAL_CIRCLE, viewerId);
      }
    }
    Record rec =
        fs.setFriendP(ctx, viewerId, friendId, circleIds, Constants.FRIEND_REASON_MANUALSELECT);

    if (qp.containsKey("from_email")) {
      String notice = "Operate Success!";
      String html =
          pageTemplate.merge(
              "notice.ftl",
              new Object[][] {
                {"host", serverHost},
                {"notice", notice}
              });

      resp.setContentType("text/html");
      resp.getWriter().print(html);
    } else {
      output(qp, req, resp, rec.toString(false, false), 200, "text/plain");
    }
    // add by wangpeng for delay and combine email

    try {
      List list = new ArrayList<String>();
      list.add(qp.checkGetString("friendId"));
      MessageDelayCombineUtils.sendEmailCombineAndDelayNewFollower(
          ctx, ctx.getViewerIdString(), list);
    } catch (Exception e) {
      L.error(ctx, e, "delay and combine new follower email error!@@@@");
    }
    return NoResponse.get();
  }
  @WebMethod("friend/mutual")
  public NoResponse mutualFriend(QueryParams qp, HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    final String SERVER_HOST = GlobalConfig.get().getString("server.host", "api.borqs.com");
    ;

    FriendshipLogic fs = GlobalLogics.getFriendship();

    Context ctx = WutongContext.getContext(qp, false);
    String userId = qp.checkGetString("user_id");
    String fromId = qp.checkGetString("from_id");
    try {
      fs.setFriendsP(
          ctx,
          userId,
          fromId,
          String.valueOf(Constants.ACQUAINTANCE_CIRCLE),
          Constants.FRIEND_REASON_INVITE,
          true);
      fs.setFriendsP(
          ctx,
          fromId,
          userId,
          String.valueOf(Constants.ACQUAINTANCE_CIRCLE),
          Constants.FRIEND_REASON_INVITE,
          true);
      fs.setFriendsP(
          ctx,
          userId,
          fromId,
          String.valueOf(Constants.ADDRESS_BOOK_CIRCLE),
          Constants.FRIEND_REASON_INVITE,
          true);
      fs.setFriendsP(
          ctx,
          fromId,
          userId,
          String.valueOf(Constants.ADDRESS_BOOK_CIRCLE),
          Constants.FRIEND_REASON_INVITE,
          true);
    } catch (Exception e) {
      String html =
          pageTemplate.merge(
              "notice.ftl",
              new Object[][] {
                {"host", SERVER_HOST},
                {"notice", "互相加为好友失败,请稍后再试。"}
              });
      resp.setContentType("text/html");
      resp.getWriter().print(html);

      return NoResponse.get();
    }

    String html =
        pageTemplate.merge(
            "notice.ftl",
            new Object[][] {
              {"host", SERVER_HOST},
              {"notice", "互相加为好友成功!"}
            });
    resp.setContentType("text/html");
    resp.getWriter().print(html);

    return NoResponse.get();
  }