}
ObjectId originalTargetId = extraMetadata.get("messageEventTargetId") != null ?
(ObjectId)extraMetadata.get("messageEventTargetId") :
null;
Event previousEvent = getLastEventForTarget(originalTargetId);
// Try to get the user
ObjectId originalEventUserId = extraMetadata.get("messageEventUserId") != null ?
(ObjectId)extraMetadata.get("messageEventUserId") :
null;
if (originalEventUserId != null) {
try {
user = userService.getUserById(originalEventUserId);
} catch (UserNotFoundException unfe) {
if (previousEvent != null) {
try {
user = userService.getUserById(previousEvent.getUserId());
} catch (UserNotFoundException unfe2) {
// There is nothing we can do at this point. Let's log so we can keep
// track of these unrecoverable events
logger.error("Unable to identify the sender of the SobaMessage " +
"having an id of " + target.getId());
}
}
}
}
// Try to get the account
ObjectId originalEventAccountId = extraMetadata.get("messageEventAccountId") != null ?
(ObjectId)extraMetadata.get("messageEventAccountId") :
null;
if (originalEventAccountId != null) {
try {
account = userService.getAccount(originalEventAccountId);
} catch (AccountNotFoundException anfe) {
if (previousEvent != null) {
try {
account = userService.getAccount(previousEvent.getAccountId());
} catch (AccountNotFoundException anfe2) {
// There is nothing we can do at this point. Let's log so we can
// keep track of these unrecoverable events
logger.error("Unable to identify the sender of the SobaMessage " +
"having an id of " + target.getId());