use of com.pratilipi.data.type.User in project pratilipi by Pratilipi.
the class EmailDataUtil method _updateUserEntity.
private static void _updateUserEntity(Long userId) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
User user = dataAccessor.getUser(userId);
AuditLog auditLog = dataAccessor.newAuditLog(AccessTokenFilter.getAccessToken(), AccessType.USER_UPDATE, user);
user.setLastEmailedDate(new Date());
user.setLastUpdated(new Date());
user = dataAccessor.createOrUpdateUser(user, auditLog);
}
use of com.pratilipi.data.type.User in project pratilipi by Pratilipi.
the class ConversationDataUtil method saveMessage.
public static void saveMessage(ContactTeam team, Long userId, String name, String email, String phone, String message, JsonObject data) throws InvalidArgumentException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
User user = dataAccessor.getUser(userId);
Author author = dataAccessor.getAuthorByUserId(userId);
Conversation conversation = dataAccessor.getConversation(team, userId);
if (conversation == null)
dataAccessor.getConversation(team, email);
if (conversation != null) {
// Do Nothing !
} else if (user != null && (user.getState() == UserState.ACTIVE || user.getState() == UserState.REGISTERED)) {
// &&
// conversation
// ==
// null
conversation = dataAccessor.newConversation(team, userId);
conversation.setCreator(userId);
conversation.setCreatorName(name);
conversation.setCreatorEmail(email);
conversation.setCreatorPhone(phone);
conversation.setCreationDate(new Date());
List<ConversationUser> conversationUserList = new ArrayList<>(team.getUserIds().length + 1);
conversationUserList.add(dataAccessor.newConversationUser(conversation.getId(), userId));
for (Long recipientUserId : team.getUserIds()) conversationUserList.add(dataAccessor.newConversationUser(conversation.getId(), recipientUserId));
conversation = dataAccessor.createOrUpdateConversation(conversation, conversationUserList);
} else if (email != null) {
// && conversation == null
conversation = dataAccessor.newConversation(team, email);
conversation.setCreatorName(name);
conversation.setCreatorEmail(email);
conversation.setCreatorPhone(phone);
conversation.setCreationDate(new Date());
List<ConversationUser> conversationUserList = new ArrayList<>(team.getUserIds().length + 1);
for (Long recipientUserId : team.getUserIds()) conversationUserList.add(dataAccessor.newConversationUser(conversation.getId(), recipientUserId));
conversation = dataAccessor.createOrUpdateConversation(conversation, conversationUserList);
} else {
throw new InvalidArgumentException("Valid 'email' is required.");
}
conversation.setLastUpdated(new Date());
ConversationMessage conversationMessage = dataAccessor.newConversationMessage();
conversationMessage.setConversationId(conversation.getId());
conversationMessage.setCreatorId(userId);
conversationMessage.setMessage(message);
conversationMessage.setData(data);
conversationMessage.setCreationDate(new Date());
conversation = dataAccessor.createOrUpdateConversation(conversation, conversationMessage);
String language = author != null ? author.getLanguage().getNameEn().toLowerCase() : null;
try {
ArrayList<String> receiverList = createReceiversId(team.name().toLowerCase(), language);
createSupportMailTask(receiverList, userId.toString(), name, email, phone, message, data, team.name(), language);
} catch (UnsupportedEncodingException | UnexpectedServerException e) {
logger.log(Level.SEVERE, "Exception while creating conversation mail task");
logger.log(Level.SEVERE, "User ID : " + userId);
logger.log(Level.SEVERE, "Conversation Id : " + conversation.getId());
e.printStackTrace();
}
}
use of com.pratilipi.data.type.User in project pratilipi by Pratilipi.
the class AuthorDataUtil method updateAuthorSearchIndex.
public static void updateAuthorSearchIndex(Long authorId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
Author author = dataAccessor.getAuthor(authorId);
if (author.getState() == AuthorState.ACTIVE) {
User user = author.getUserId() == null ? null : dataAccessor.getUser(author.getUserId());
searchAccessor.indexAuthorData(createAuthorData(author), UserDataUtil.createUserData(user));
} else {
searchAccessor.deleteAuthorDataIndex(authorId);
}
}
use of com.pratilipi.data.type.User in project pratilipi by Pratilipi.
the class DataAccessorGaeImpl method getUserByGoogleId.
@Override
public User getUserByGoogleId(String googleId) {
String memcacheId = "DataStore.User-google::" + googleId;
User user = memcache.get(memcacheId);
if (user != null)
return user;
user = ObjectifyService.ofy().load().type(UserEntity.class).filter("GOOGLE_ID", googleId).filter("STATE !=", UserState.DELETED).order("STATE").order("SIGN_UP_DATE").first().now();
if (user != null)
memcache.put(memcacheId, user);
return user;
}
use of com.pratilipi.data.type.User in project pratilipi by Pratilipi.
the class DataAccessorGaeImpl method getUserByFacebookId.
@Override
public User getUserByFacebookId(String facebookId) {
String memcacheId = "DataStore.User-fb::" + facebookId;
User user = memcache.get(memcacheId);
if (user != null)
return user;
user = ObjectifyService.ofy().load().type(UserEntity.class).filter("FACEBOOK_ID", facebookId).filter("STATE !=", UserState.DELETED).order("STATE").order("SIGN_UP_DATE").first().now();
if (user != null)
memcache.put(memcacheId, user);
return user;
}
Aggregations