use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.
the class NotificationRestController method getWebsocketEndpoint.
@GetMapping("/websocketEndpoint")
public final String getWebsocketEndpoint() {
userSession.assertLoggedIn();
final UserId adUserId = userSession.getLoggedUserId();
return userNotificationsService.getWebsocketEndpoint(adUserId);
}
use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.
the class NotificationRestController method markAsRead.
@PutMapping("/{notificationId}/read")
public void markAsRead(@PathVariable("notificationId") final String notificationId) {
userSession.assertLoggedIn();
final UserId adUserId = userSession.getLoggedUserId();
userNotificationsService.markNotificationAsRead(adUserId, notificationId);
}
use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.
the class MenuTreeRepository method setFavorite.
public void setFavorite(final MenuNode menuNode, final boolean favorite) {
final int adMenuId = menuNode.getAD_Menu_ID();
final UserMenuFavorites userMenuFavorites = getUserMenuFavorites();
final UserId adUserId = userMenuFavorites.getAdUserId();
// Update in database first
if (favorite) {
Services.get(IUserMenuFavoritesDAO.class).add(adUserId, adMenuId);
} else {
Services.get(IUserMenuFavoritesDAO.class).remove(adUserId, adMenuId);
}
// Update model
userMenuFavorites.setFavorite(adMenuId, favorite);
}
use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.
the class UserNotificationsService method forwardEventToNotificationsQueues.
private void forwardEventToNotificationsQueues(final IEventBus eventBus, final Event event) {
logger.trace("Got event from {}: {}", eventBus, event);
final UserNotification notification = UserNotificationUtils.toUserNotification(event);
final UserId recipientUserId = UserId.ofRepoId(notification.getRecipientUserId());
final UserNotificationsQueue notificationsQueue = getNotificationsQueueOrNull(recipientUserId);
if (notificationsQueue == null) {
logger.trace("No notification queue was found for recipientUserId={}", recipientUserId);
return;
}
notificationsQueue.addNotification(notification);
}
use of de.metas.user.UserId in project metasfresh-webui-api by metasfresh.
the class MailRestController method createNewEmail.
@PostMapping()
@ApiOperation("Creates a new email")
public JSONEmail createNewEmail(@RequestBody final JSONEmailRequest request) {
userSession.assertLoggedIn();
final UserId adUserId = userSession.getLoggedUserId();
usersService.assertCanSendEMail(adUserId);
final IntegerLookupValue from = IntegerLookupValue.of(adUserId.getRepoId(), userSession.getUserFullname() + " <" + userSession.getUserEmail() + "> ");
final DocumentPath contextDocumentPath = JSONDocumentPath.toDocumentPathOrNull(request.getDocumentPath());
final BoilerPlateContext attributes = documentCollection.createBoilerPlateContext(contextDocumentPath);
final Integer toUserId = attributes.getAD_User_ID();
final LookupValue to = mailRepo.getToByUserId(toUserId);
final String emailId = mailRepo.createNewEmail(adUserId, from, to, contextDocumentPath).getEmailId();
if (contextDocumentPath != null) {
try {
final DocumentPrint contextDocumentPrint = documentCollection.createDocumentPrint(contextDocumentPath);
attachFile(emailId, () -> mailAttachmentsRepo.createAttachment(emailId, contextDocumentPrint.getFilename(), contextDocumentPrint.getReportData()));
} catch (final Exception ex) {
logger.debug("Failed creating attachment from document print of {}", contextDocumentPath, ex);
}
}
return JSONEmail.of(mailRepo.getEmail(emailId), userSession.getAD_Language());
}
Aggregations