use of com.pratilipi.data.client.AuthorData in project pratilipi by Pratilipi.
the class EmailDataUtil method _createDataModelForAuthorFollowEmail.
private static Object[] _createDataModelForAuthorFollowEmail(String userAuthorId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
// Hack
Long userId = Long.parseLong(userAuthorId.substring(0, userAuthorId.indexOf("-")));
Long authorId = Long.parseLong(userAuthorId.substring(userAuthorId.indexOf("-") + 1));
logger.log(Level.INFO, "userId::" + userId);
logger.log(Level.INFO, "authorId::" + authorId);
UserData user = UserDataUtil.createUserData(dataAccessor.getUser(userId));
AuthorData follower = AuthorDataUtil.createAuthorData(dataAccessor.getAuthorByUserId(userId));
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("follower_name", follower.getName() != null ? follower.getName() : follower.getNameEn());
dataModel.put("follower_page_url", _getDomainName(follower.getLanguage()) + follower.getPageUrl());
dataModel.put("follower_profile_image_url", follower.getProfileImageUrl(50));
return new Object[] { dataModel, user.getLanguage() };
}
use of com.pratilipi.data.client.AuthorData in project pratilipi by Pratilipi.
the class UserV1Api method post.
@Post
public Response post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
UserData userData = request.userId == null ? new UserData(AccessTokenFilter.getAccessToken().getUserId()) : new UserData(request.userId.equals(0L) ? null : request.userId);
if (request.hasName) {
String firstName = request.name.trim();
String lastName = null;
if (firstName.lastIndexOf(' ') != -1) {
lastName = firstName.substring(firstName.lastIndexOf(' ') + 1);
firstName = firstName.substring(0, firstName.lastIndexOf(' '));
}
userData.setFirstName(firstName);
userData.setLastName(lastName);
}
if (request.hasEmail)
userData.setEmail(request.email);
if (request.hasPhone)
userData.setPhone(request.phone);
if (request.hasLanguage)
userData.setLanguage(request.language);
// Save UserData
userData = UserDataUtil.saveUserData(userData);
// New User (added by AEE)
if (request.userId != null && request.userId.equals(0L)) {
// Create Author profile for the User
Long authorId = AuthorDataUtil.createAuthorProfile(userData, request.language == null ? UxModeFilter.getFilterLanguage() : request.language);
userData.setAuthor(new AuthorData(authorId));
userData.setProfilePageUrl("/author/" + authorId);
// Send welcome mail to the user
Task task = TaskQueueFactory.newTask().setUrl("/user/email").addParam("userId", userData.getId().toString()).addParam("language", request.language == null ? UxModeFilter.getDisplayLanguage().toString() : request.language.toString()).addParam("sendWelcomeMail", "true");
TaskQueueFactory.getUserTaskQueue().add(task);
}
return new Response(userData);
}
Aggregations