Beispiel #1
0
  @Override
  public int updateHotFriendMemo(int host, int friend, String memo) {
    // 1.判断host是否是星级用户
    // 2.判断host与friend是否为好友关系
    // 3.rpc to hotfriendcache
    if (!hasHotFriendRight(host)) {
      return Constants.INVALID_USER;
    }

    if (!FriendUtil.isFriend(host, friend)) {
      return Constants.FAIL;
    }

    try {
      HotFriendData data = new HotFriendData(friend, memo);
      BuddyHotCacheAdapter.getInstance().addHotFriend(host, data);
    } catch (Exception e) {
      e.printStackTrace();
      return Constants.ERROR;
    }

    return Constants.SUCCESS;
  }
Beispiel #2
0
  @Override
  public int setHotFriend(int host, List<Integer> friends) {
    // 1.判断host是否是星级用户,星级用户最多10个特别好友,非星级6个!
    // 2.判断host与friens的好友关系,过滤掉friends列表中非好友的friend_id
    // 3.组装HotFriendData列表,处理一下position,按列表自然顺序
    // 4.rpc to hotfriendcache

    if (friends == null) {
      return Constants.ERROR;
    }

    if (!hasHotFriendRight(host)) {
      return Constants.INVALID_USER;
    }
    int maxHotFriendCount = FriendUtil.maxHotFriendCount(threadLocalUser.get());
    Map<Integer, Boolean> isFriendMap = FriendUtil.isFriend(host, friends);
    List<HotFriendData> dataList = new ArrayList<HotFriendData>();
    int position = 0;
    for (int i = 0; i < friends.size() && position < maxHotFriendCount; i++, position++) {
      int friend = friends.get(i);
      if (isFriendMap.containsKey(friend) && isFriendMap.get(friend)) {
        HotFriendData data =
            new HotFriendData(
                friend, position, System.currentTimeMillis(), HotFriendData.DEFAULT_MEMO);
        dataList.add(data);
      }
    }
    try {
      BuddyHotCacheAdapter.getInstance().setHotFriend(host, dataList);
    } catch (Exception e) {
      e.printStackTrace();
      return Constants.ERROR;
    }

    return Constants.SUCCESS;
  }