@Override public void setFriendIntoCircles(Context ctx, int reason, PeopleId friendId, int... circleIds) { ParamChecker.notNull("ctx", ctx); ParamChecker.notNull("friendId", friendId); ParamChecker.notNull("circleIds", circleIds); long viewerId = ctx.getViewer(); AccountHelper.checkUser(account, ctx, viewerId); FriendEntries fes = getFriendEntries(ctx, viewerId); if (fes == null || !fes.hasAllCircles(circleIds)) throw new ServerException(E.INVALID_CIRCLE); FriendEntry fe = fes.ensureFriend(friendId); fe.setCircles(reason, DateHelper.nowMillis(), circleIds); putFriendEntries(viewerId, fes); }
@Override public Circle createCustomCircle(Context ctx, String circleName) { ParamChecker.notNull("ctx", ctx); long viewerId = ctx.getViewer(); AccountHelper.checkUser(account, ctx, viewerId); FriendEntries fes = getFriendEntries(ctx, viewerId); int[] customCircleIds = fes.circles.getCircleIds(Circle.MIN_CUSTOM_CIRCLE_ID); int newCircleId = newCircleId(customCircleIds); if (newCircleId < 0) throw new ServerException(E.TOO_MANY_CIRCLES, "Too many circles"); Circle newCircle = new Circle(newCircleId, circleName, DateHelper.nowMillis(), null); fes.circles.add(newCircle); putFriendEntries(viewerId, fes); return newCircle; }
public boolean destroyComments(final Context ctx, final long... commentIds) { if (ArrayUtils.isEmpty(commentIds)) return true; final long now = DateHelper.nowMillis(); final ShardResult commentSR = shardComment(); return sqlExecutor.openConnection( commentSR.db, new SingleConnectionHandler<Boolean>() { @Override protected Boolean handleConnection(Connection conn) { String sql = CommentSql.disableComments(ctx, commentSR.table, now, commentIds); long n = SqlExecutor.executeUpdate(ctx, conn, sql); return n > 0; } }); }
@Override public void addFriendsIntoCircle(Context ctx, int reason, PeopleIds friendIds, int circleId) { ParamChecker.notNull("ctx", ctx); ParamChecker.notNull("friendIds", friendIds); ParamChecker.notNull("circleI", circleId); long viewerId = ctx.getViewer(); AccountHelper.checkUser(account, ctx, viewerId); long now = DateHelper.nowMillis(); FriendEntries fes = getFriendEntries(ctx, viewerId); if (fes == null || !fes.hasCircle(circleId)) throw new ServerException(E.INVALID_CIRCLE); for (PeopleId friendId : friendIds) { FriendEntry fe = fes.ensureFriend(friendId); fe.addCircle(circleId, reason, now); } putFriendEntries(viewerId, fes); }