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

SAK-49287 Notifications. Improved push permissions workflow #11947

Merged
merged 12 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.sakaiproject.messaging.api;

import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -59,9 +58,6 @@ public interface UserMessagingService {
*/
boolean importTemplateFromResourceXmlFile(String templateResource, String templateRegistrationKey);

public void listen(String topic, MessageListener listener);
public void send(String topic, UserNotification ba);

/**
* @return the list of notifications for the current user
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ignite.IgniteMessaging;
import org.apache.http.HttpResponse;

import org.bouncycastle.jce.ECNamedCurveTable;
Expand Down Expand Up @@ -67,12 +66,10 @@
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.event.api.NotificationService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.ignite.EagerIgniteSpringBean;
import org.sakaiproject.messaging.api.model.UserNotification;
import org.sakaiproject.messaging.api.UserNotificationData;
import org.sakaiproject.messaging.api.UserNotificationHandler;
import org.sakaiproject.messaging.api.Message;
import org.sakaiproject.messaging.api.MessageListener;
import org.sakaiproject.messaging.api.MessageMedium;
import org.sakaiproject.messaging.api.model.PushSubscription;
import org.sakaiproject.messaging.api.model.UserNotification;
Expand Down Expand Up @@ -121,24 +118,27 @@ public class UserMessagingServiceImpl implements UserMessagingService, Observer
@Autowired private EmailTemplateService emailTemplateService;
@Autowired private EntityManager entityManager;
@Autowired private EventTrackingService eventTrackingService;
@Autowired private EagerIgniteSpringBean ignite;
@Autowired private PreferencesService preferencesService;
@Autowired private PushSubscriptionRepository pushSubscriptionRepository;
@Autowired private ServerConfigurationService serverConfigurationService;

@Qualifier("org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory")
@Autowired private SessionFactory sessionFactory;

@Autowired private SessionManager sessionManager;
@Autowired private SiteService siteService;
@Autowired private ToolManager toolManager;
@Autowired private UserDirectoryService userDirectoryService;
@Autowired private UserNotificationRepository userNotificationRepository;

@Qualifier("org.sakaiproject.time.api.UserTimeService")
@Autowired private UserTimeService userTimeService;

@Setter private ResourceLoader resourceLoader;

@Qualifier("org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
@Autowired private PlatformTransactionManager transactionManager;

private IgniteMessaging messaging;
private List<UserNotificationHandler> handlers = new ArrayList<>();
private Map<String, UserNotificationHandler> handlerMap = new HashMap<>();
private ExecutorService executor;
Expand All @@ -161,8 +161,6 @@ public void init() {

objectMapper.registerModule(new JavaTimeModule());

messaging = ignite.message(ignite.cluster().forLocal());

Security.addProvider(new BouncyCastleProvider());

executor = Executors.newFixedThreadPool(20);
Expand Down Expand Up @@ -593,20 +591,6 @@ private UserNotification decorateNotification(UserNotification notification) {
return notification;
}


public void listen(String topic, MessageListener listener) {

messaging.localListen(topic, (nodeId, message) -> {

listener.read(decorateNotification((UserNotification) message));
return true;
});
}

public void send(String topic, UserNotification un) {
messaging.send(topic, un);
}

@Transactional
public void subscribeToPush(String endpoint, String auth, String userKey, String browserFingerprint) {

Expand Down
1 change: 1 addition & 0 deletions library/src/skins/default/src/sass/base/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ $fa-font-path: "./fonts";
pin-fill: bi-pin-fill,
eye-slash-fill: bi-eye-slash-fill,
question: bi-question,
warning: bi-exclamation-lg,
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,18 @@
.portal-notifications-button {
position: relative;
}
.portal-notifications-indicator {
.portal-notifications-indicator, .portal-notifications-no-permissions-indicator {
position: absolute;
top: 10;
top: 10px;
right: 20%;
}

.portal-notifications-no-permissions-indicator {
top: 0px;
right: 23%;
color: red;
}

// make offcanvas header match Sakai's header:
.offcanvas-header {
flex-shrink: 0;
Expand Down
4 changes: 4 additions & 0 deletions library/src/webapp/js/portal/portal.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".portal-search-button").forEach(b => {
b.addEventListener("click", () => portal.search.setup({}));
});

if (portal?.user?.id && Notification?.permission !== "granted") {
document.querySelectorAll(".portal-notifications-no-permissions-indicator").forEach(b => b.classList.remove("d-none"));
}
});
182 changes: 0 additions & 182 deletions library/src/webapp/js/sakai-message-broker.js

This file was deleted.

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<module>samigo</module>
<module>search</module>
<module>sections</module>
<module>serviceworker</module>
<module>shortenedurl</module>
<module>signup</module>
<module>simple-rss-portlet</module>
Expand Down
2 changes: 2 additions & 0 deletions portal/portal-impl/impl/src/bundle/sitenav.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ sit_notermkey = Courses: No Term
sit_moretab_inst = <em>Hidden Sites</em> are not included in this menu. Access them in Home -&gt; Worksite Setup.<br /> To hide a site, go to Home -> Preferences -> Customize Tabs.
sit_selectmessage = To operate the combo box, first press Alt+Down Arrow to open it, and then use the up and down arrow keys to scroll through the options.
sit_notifications = View your notifications
sit_notifications_not_permitted_label=Notifications have not yet been permitted
sit_new_notifications_label=There are new notifications available
sit_navigation = View the site navigation
sit_account = View your account details
sit_mywor = Home
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,9 @@ public PortalNotifications handleNotify(EntityView view) {
@EntityCustomAction(action = "notifications", viewKey = EntityView.VIEW_LIST)
public ActionReturn getNotifications(EntityView view) {

String currentUserId = getCheckedCurrentUser();

ResourceLoader rl = new ResourceLoader("bullhorns");
List<UserNotification> notifications = userMessagingService.getNotifications();

Map<String, Object> data = new HashMap<>();
data.put("i18n", rl);

if (notifications.size() > 0) {
data.put("notifications", notifications);
}
getCheckedCurrentUser();

return new ActionReturn(data);
return new ActionReturn(userMessagingService.getNotifications());
}

@EntityCustomAction(action = "clearNotification", viewKey = EntityView.VIEW_LIST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ For opening help sidebar
aria-controls="sakai-notificationsPanel"
aria-label="$rloader.sit_notifications"
title="$rloader.sit_notifications">
<i class="bi-bell"></i>
<span class="portal-notifications-indicator p-1 bg-danger rounded-circle" style="display: none">
<span class="visually-hidden">There are new notifications available</span>
<i class="portal-notifications-icon bi-bell"></i>
<i class="portal-notifications-no-permissions-indicator si si-warning d-none"
aria-label="$rloader.sit_notifications_not_permitted_label">
adrianfish marked this conversation as resolved.
Show resolved Hide resolved
</i>
<span class="portal-notifications-indicator p-1 bg-danger rounded-circle d-none">
<span class="visually-hidden">$rloader.sit_new_notifications_label</span>
</span>
</button>
</li>
Expand Down
Loading
Loading