use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.
the class UserLoginFacebookApi method post.
@Post
public UserV1Api.Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException, UnexpectedServerException {
UserData userData = UserDataUtil.loginFacebookUser(request.fbUserAccessToken, UserDataUtil.getUserSignUpSource(true, false));
List<Task> taskList = new LinkedList<>();
Task fbValidationTask = TaskQueueFactory.newTask().setUrl("/user/facebook/validation").addParam("accessToken", AccessTokenFilter.getAccessToken().getId()).addParam("fbUserAccessToken", request.fbUserAccessToken);
taskList.add(fbValidationTask);
if (new Date().getTime() - userData.getSignUpDate().getTime() <= 60000) {
Long authorId = AuthorDataUtil.createAuthorProfile(userData, request.language == null ? UxModeFilter.getFilterLanguage() : request.language);
// Fetching updated UserData
userData = UserDataUtil.getCurrentUser();
if (userData.getEmail() != null) {
// Send welcome mail to the user
Task welcomeMailTask = TaskQueueFactory.newTask().setUrl("/user/email").addParam("userId", userData.getId().toString()).addParam("language", (request.language == null ? (UxModeFilter.getDisplayLanguage() == null ? Language.ENGLISH : UxModeFilter.getDisplayLanguage()) : request.language).toString()).addParam("sendWelcomeMail", "true");
taskList.add(welcomeMailTask);
}
// Process Author data
Task task = TaskQueueFactory.newTask().setUrl("/author/process").addParam("authorId", authorId.toString()).addParam("processData", "true");
TaskQueueFactory.getAuthorTaskQueue().add(task);
}
TaskQueueFactory.getUserTaskQueue().addAll(taskList);
return new UserV1Api.Response(userData, UserLoginFacebookApi.class);
}
use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.
the class UserLoginGoogleApi method post.
@Post
public UserV1Api.Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException, UnexpectedServerException {
UserData userData = UserDataUtil.loginGoogleUser(request.googleIdToken, UserDataUtil.getUserSignUpSource(false, true));
if (new Date().getTime() - userData.getSignUpDate().getTime() <= 60000) {
Long authorId = AuthorDataUtil.createAuthorProfile(userData, request.language == null ? UxModeFilter.getFilterLanguage() : request.language);
// Fetching updated UserData
userData = UserDataUtil.getCurrentUser();
// Send welcome mail to the user
Task welcomeMailTask = TaskQueueFactory.newTask().setUrl("/user/email").addParam("userId", userData.getId().toString()).addParam("language", (request.language == null ? (UxModeFilter.getDisplayLanguage() == null ? Language.ENGLISH : UxModeFilter.getDisplayLanguage()) : request.language).toString()).addParam("sendWelcomeMail", "true");
TaskQueueFactory.getUserTaskQueue().add(welcomeMailTask);
// Process Author data
Task task = TaskQueueFactory.newTask().setUrl("/author/process").addParam("authorId", authorId.toString()).addParam("processData", "true");
TaskQueueFactory.getAuthorTaskQueue().add(task);
}
return new UserV1Api.Response(userData, UserLoginGoogleApi.class);
}
use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.
the class UserPasswordUpdateApi method post.
@Post
public UserV1Api.Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
UserData userData;
if (request.getEmail() != null && request.getVerificationToken() != null) {
// Verifying email
UserDataUtil.verifyUserEmail(request.getEmail(), request.getVerificationToken());
// Updating password
UserDataUtil.updateUserPassword(request.getEmail(), request.getVerificationToken(), request.getNewPassword());
// Logging-in the user
userData = UserDataUtil.loginUser(request.getEmail(), request.getVerificationToken());
} else if (request.getPassword() != null) {
// Updating password
UserDataUtil.updateUserPassword(request.getPassword(), request.getNewPassword());
userData = UserDataUtil.getCurrentUser();
} else {
throw new InvalidArgumentException(GenericRequest.ERR_INSUFFICIENT_ARGS);
}
return new UserV1Api.Response(userData, UserPasswordUpdateApi.class);
}
use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.
the class UserPratilipiReviewApi method post.
@Post
public UserPratilipiApi.Response post(PostRequest request) throws InsufficientAccessException, UnexpectedServerException {
UserPratilipiData userPratilipiData = UserPratilipiDataUtil.saveUserPratilipiReview(AccessTokenFilter.getAccessToken().getUserId(), request.pratilipiId, request.rating, request.review, request.reviewState);
Task task = TaskQueueFactory.newTask().setUrl("/pratilipi/process").addParam("pratilipiId", request.pratilipiId.toString()).addParam("updateReviewsDoc", "true").addParam("updateUserPratilipiStats", "true");
TaskQueueFactory.getPratilipiTaskQueue().add(task);
return new UserPratilipiApi.Response(userPratilipiData, UserPratilipiReviewApi.class);
}
use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.
the class UserAuthorFollowV2Api method post.
@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
Long userId = AccessTokenFilter.getAccessToken().getUserId();
UserAuthorData userAuthorData = UserAuthorDataUtil.saveUserAuthorFollow(userId, request.authorId, request.state);
Task task_1 = TaskQueueFactory.newTask().setUrl("/author/process").addParam("authorId", request.authorId.toString()).addParam("updateUserAuthorStats", "true");
Task task_2 = TaskQueueFactory.newTask().setUrl("/user/process").addParam("userId", userId.toString()).addParam("updateFollowsDoc", "true").addParam("updateUserAuthorStats", "true");
TaskQueueFactory.getUserAuthorTaskQueue().addAll(task_1, task_2);
return new Response(userAuthorData);
}
Aggregations