Skip to content

Commit

Permalink
SAK-29529 High Priority Future Announcements not being emailed
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Holladay committed Jun 17, 2015
1 parent 93fbe1c commit 2a032f7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ public Map<String, String> transferCopyEntitiesRefMigrator(String fromContext, S
p.addAll(oProperties);

// complete the edit
nChannel.commitMessage(nMessage, NotificationService.NOTI_NONE);
nChannel.commitMessage(nMessage, NotificationService.NOTI_IGNORE);

// transversalMap.put(oMessage.getReference(), nMessage.getReference());
}
Expand Down Expand Up @@ -1430,7 +1430,7 @@ public void updateEntityReferences(String toContext, Map<String, String> transve
if(updated){
AnnouncementMessageEdit editMsg = aChannel.editAnnouncementMessage(msg.getId());
editMsg.setBody(msgBody);
aChannel.commitMessage(editMsg, NotificationService.NOTI_NONE);
aChannel.commitMessage(editMsg, NotificationService.NOTI_IGNORE);
}
}
}
Expand Down Expand Up @@ -1668,7 +1668,7 @@ private void setMessageUnreleasedMax(int currentMax) {
try {
AnnouncementMessageEdit em = editAnnouncementMessage(me.getId());
em.getHeaderEdit().setMessage_order(++currentMax);
super.commitMessage(em, NotificationService.NOTI_NONE, "");
super.commitMessage(em, NotificationService.NOTI_IGNORE, "");
} catch (InUseException e) {
if (M_log.isDebugEnabled()) {
M_log.debug("Exception moving an unreleased item.",e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public interface NotificationService

/** ability / event for notification removal. */
static final String SECURE_REMOVE_NOTIFICATION = "notification.remove";

/** Notification option value to tell API to skip notification logic. */
static final int NOTI_IGNORE = -1;

/** Notification option value for undefined or no notification. */
static final int NOTI_NONE = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2696,38 +2696,41 @@ public void commitMessage(MessageEdit edit, int priority, String invokee)
// update the properties
// addLiveUpdateProperties(edit.getPropertiesEdit());//%%%

// if this message had a future invocation before, delete it because
// this modification changed the date of release so either it will notify it now
// or set a new future notification
ScheduledInvocationManager scheduledInvocationManager = (ScheduledInvocationManager)
ComponentManager.get(org.sakaiproject.api.app.scheduler.ScheduledInvocationManager.class);

if (edit.getProperties().getProperty(SCHED_INV_UUID) != null)
{
scheduledInvocationManager.deleteDelayedInvocation(edit.getProperties().getProperty(SCHED_INV_UUID));
edit.getPropertiesEdit().removeProperty(SCHED_INV_UUID);
boolean transientNotification = true;
if(priority != NotificationService.NOTI_IGNORE){
// if this message had a future invocation before, delete it because
// this modification changed the date of release so either it will notify it now
// or set a new future notification
ScheduledInvocationManager scheduledInvocationManager = (ScheduledInvocationManager)
ComponentManager.get(org.sakaiproject.api.app.scheduler.ScheduledInvocationManager.class);

if (edit.getProperties().getProperty(SCHED_INV_UUID) != null)
{
scheduledInvocationManager.deleteDelayedInvocation(edit.getProperties().getProperty(SCHED_INV_UUID));
edit.getPropertiesEdit().removeProperty(SCHED_INV_UUID);

// Event event = m_eventTrackingService.newEvent(SCHINV_DELETE_EVENT, edit.getReference(), true, priority);
// m_eventTrackingService.post(event);
}
// Event event = m_eventTrackingService.newEvent(SCHINV_DELETE_EVENT, edit.getReference(), true, priority);
// m_eventTrackingService.post(event);
}

// For Scheduled Notification, compare header date with now to deterine
// if an immediate notification is needed or a scheduled one
// Put here since need to store uuid for notification just in case need to
// delete/modify
Time now = m_timeService.newTime();
boolean transientNotification = true;

if (now.before(edit.getHeader().getDate()) && priority != NotificationService.NOTI_NONE)
{
final String uuid = scheduledInvocationManager.createDelayedInvocation(edit.getHeader().getDate(),
invokee, edit.getReference());

final ResourcePropertiesEdit editProps = edit.getPropertiesEdit();

editProps.addProperty(SCHED_INV_UUID, uuid);
// For Scheduled Notification, compare header date with now to deterine
// if an immediate notification is needed or a scheduled one
// Put here since need to store uuid for notification just in case need to
// delete/modify
Time now = m_timeService.newTime();

transientNotification = false;

if (now.before(edit.getHeader().getDate()) && priority != NotificationService.NOTI_NONE)
{
final String uuid = scheduledInvocationManager.createDelayedInvocation(edit.getHeader().getDate(),
invokee, edit.getReference());

final ResourcePropertiesEdit editProps = edit.getPropertiesEdit();

editProps.addProperty(SCHED_INV_UUID, uuid);

transientNotification = false;
}
}

// complete the edit
Expand All @@ -2744,7 +2747,7 @@ public void commitMessage(MessageEdit edit, int priority, String invokee)
m_eventTrackingService.post(event);

// channel notification
if (transientNotification)
if (priority != NotificationService.NOTI_IGNORE && transientNotification)
{
startNotifyThread(event);
}
Expand Down

0 comments on commit 2a032f7

Please sign in to comment.