Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lps 205014 dxp master #5802

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
LPS-205014 use service context if possible
  • Loading branch information
titokenzo committed Jan 4, 2024
commit bae72d0d05bf6881285b9ce7db3489e97b42fd2a
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public class NotificationTemplateContextFactory {
public static NotificationTemplateContext getInstance(
CalendarBooking calendarBooking,
NotificationTemplateType notificationTemplateType,
NotificationType notificationType, long scopeGroupId, User user)
NotificationType notificationType, String layoutURL,
String portalURL, User user)
throws Exception {

CalendarBooking parentCalendarBooking =
Expand Down Expand Up @@ -125,6 +126,9 @@ public static NotificationTemplateContext getInstance(
).put(
"portalURL",
() -> {
if (portalURL != null){
return portalURL;
}
GroupLocalService groupLocalService =
_groupLocalServiceSnapshot.get();

Expand Down Expand Up @@ -164,7 +168,7 @@ public static NotificationTemplateContext getInstance(
).put(
"url",
_getCalendarBookingURL(
calendarBooking.getCalendarBookingId(), scopeGroupId, user)
calendarBooking.getCalendarBookingId(), layoutURL, portalURL, user)
).build();

notificationTemplateContext.setAttributes(attributes);
Expand All @@ -179,15 +183,19 @@ public static NotificationTemplateContext getInstance(
ServiceContext serviceContext)
throws Exception {

long scopeGroupId = 0L;
String portalURL = null;

String layoutURL = null;

if (serviceContext != null) {
scopeGroupId = serviceContext.getScopeGroupId();
portalURL = serviceContext.getPortalURL();

layoutURL = serviceContext.getLayoutURL();
}

NotificationTemplateContext notificationTemplateContext = getInstance(
calendarBooking, notificationTemplateType, notificationType,
scopeGroupId, user);
layoutURL, portalURL, user);

if ((serviceContext != null) &&
Validator.isNotNull(
Expand Down Expand Up @@ -218,20 +226,13 @@ public static NotificationTemplateContext getInstance(
* CalendarBooking)}
*/
private static String _getCalendarBookingURL(
long calendarBookingId, long scopeGroupId, User user)
long calendarBookingId, String layoutURL, String portalURL, User user)
throws Exception {

GroupLocalService groupLocalService = _groupLocalServiceSnapshot.get();

Group group = null;

if (scopeGroupId != 0) {
group = groupLocalService.getGroup(scopeGroupId);
}
else {
group = groupLocalService.getGroup(
Group group = groupLocalService.getGroup(
user.getCompanyId(), GroupConstants.GUEST);
}

LayoutLocalService layoutLocalService =
_layoutLocalServiceSnapshot.get();
Expand All @@ -247,12 +248,16 @@ private static String _getCalendarBookingURL(
group.getDefaultPublicPlid());
}

String portalURL = _getPortalURL(
group.getCompanyId(), group.getGroupId());
if (portalURL == null) {
portalURL = _getPortalURL(
group.getCompanyId(), group.getGroupId());
}

String layoutActualURL = PortalUtil.getLayoutActualURL(layout);
if (layoutURL == null) {
layoutURL = PortalUtil.getLayoutActualURL(layout);
}

String url = portalURL + layoutActualURL;
String url = portalURL + layoutURL;

String namespace = PortalUtil.getPortletNamespace(
CalendarPortletKeys.CALENDAR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ else if (_isInCheckInterval(
NotificationTemplateContext notificationTemplateContext =
NotificationTemplateContextFactory.getInstance(
calendarBooking, NotificationTemplateType.REMINDER,
notificationType, 0L, user);
notificationType, null, null, user);

notificationSender.sendNotification(
user.getEmailAddress(), user.getFullName(),
Expand Down