logger.trace("Add new following to the list of following.");
mapper.addFollower(followerPersonId, followedPersonId);
addCachedFollowerMapper.execute(followerPersonId, followedPersonId);
// Queue async action to remove the newly followed person from cache (to sync follower counts)
asyncRequests.add(new UserActionRequest("deleteCacheKeysAction", null, (Serializable) Collections
.singleton(CacheKeys.PERSON_BY_ID + followedPersonId)));
logger.trace("Submit async action to update all cached activities.");
// Post an async action to update the cache for the user's list of following activity ids.
asyncRequests.add(new UserActionRequest("refreshFollowedByActivities", null, followerPersonId));
// queues up new follower notifications.
asyncRequests
.add(new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null,
new TargetEntityNotificationsRequest(RequestType.FOLLOW_PERSON, followerPersonId,
followedPersonId)));
break;
case NOTFOLLOWING:
logger.trace("Remove new following from the list of following.");
mapper.removeFollower(followerPersonId, followedPersonId);
// Queue async action to remove the newly followed person from cache (to sync follower counts)
asyncRequests.add(new UserActionRequest("deleteCacheKeysAction", null, (Serializable) Collections
.singleton(CacheKeys.PERSON_BY_ID + followedPersonId)));
// Remove the current user that is severing a relationship with the target
// from the list of followers for that target user.
asyncRequests.add(new UserActionRequest("deleteIdsFromLists", null, new DeleteIdsFromListsRequest(
Collections.singletonList(CacheKeys.FOLLOWERS_BY_PERSON + followedPersonId), Collections
.singletonList(followerPersonId))));
// Remove the target user the current user is no longer following from the list of
// users that the current is already following.
asyncRequests.add(new UserActionRequest("deleteIdsFromLists", null, new DeleteIdsFromListsRequest(
Collections.singletonList(CacheKeys.PEOPLE_FOLLOWED_BY_PERSON + followerPersonId), Collections
.singletonList(followedPersonId))));
// Post an async action to update the cache for the user's list of following activity ids.
asyncRequests.add(new UserActionRequest("refreshFollowedByActivities", null, followerPersonId));
break;
default:
// do nothing.
}