mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Fixed https://github.com/DSpace/DSpace/issues/10754 by setting the context user to the current subscriber
This commit is contained in:
@@ -67,6 +67,7 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
||||
public void perform(Context context, DSpaceRunnableHandler handler, String subscriptionType, String frequency) {
|
||||
List<IndexableObject> communityItems = new ArrayList<>();
|
||||
List<IndexableObject> collectionsItems = new ArrayList<>();
|
||||
EPerson currentEperson = context.getCurrentUser();
|
||||
try {
|
||||
List<Subscription> subscriptions =
|
||||
findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, frequency);
|
||||
@@ -77,7 +78,10 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
||||
for (Subscription subscription : subscriptions) {
|
||||
DSpaceObject dSpaceObject = subscription.getDSpaceObject();
|
||||
EPerson ePerson = subscription.getEPerson();
|
||||
|
||||
// Set the current user to the subscribed eperson because the Solr query checks
|
||||
// the permissions of the current user in the ANONYMOUS group.
|
||||
// If there is no user (i.e., `current user = null`), it will send an email with no new items.
|
||||
context.setCurrentUser(ePerson);
|
||||
if (!authorizeService.authorizeActionBoolean(context, ePerson, dSpaceObject, READ, true)) {
|
||||
iterator++;
|
||||
continue;
|
||||
@@ -126,6 +130,8 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
||||
handler.handleException(e);
|
||||
context.abort();
|
||||
}
|
||||
// Reset the current user because it was changed to subscriber eperson
|
||||
context.setCurrentUser(currentEperson);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
Reference in New Issue
Block a user