mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 05:23:14 +00:00
Fixed https://github.com/DSpace/DSpace/issues/10754 by setting the context user to the current subscriber
(cherry picked from commit 6275d3b756
)
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) {
|
public void perform(Context context, DSpaceRunnableHandler handler, String subscriptionType, String frequency) {
|
||||||
List<IndexableObject> communityItems = new ArrayList<>();
|
List<IndexableObject> communityItems = new ArrayList<>();
|
||||||
List<IndexableObject> collectionsItems = new ArrayList<>();
|
List<IndexableObject> collectionsItems = new ArrayList<>();
|
||||||
|
EPerson currentEperson = context.getCurrentUser();
|
||||||
try {
|
try {
|
||||||
List<Subscription> subscriptions =
|
List<Subscription> subscriptions =
|
||||||
findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, frequency);
|
findAllSubscriptionsBySubscriptionTypeAndFrequency(context, subscriptionType, frequency);
|
||||||
@@ -77,7 +78,10 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
|||||||
for (Subscription subscription : subscriptions) {
|
for (Subscription subscription : subscriptions) {
|
||||||
DSpaceObject dSpaceObject = subscription.getDSpaceObject();
|
DSpaceObject dSpaceObject = subscription.getDSpaceObject();
|
||||||
EPerson ePerson = subscription.getEPerson();
|
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)) {
|
if (!authorizeService.authorizeActionBoolean(context, ePerson, dSpaceObject, READ, true)) {
|
||||||
iterator++;
|
iterator++;
|
||||||
continue;
|
continue;
|
||||||
@@ -126,6 +130,8 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
|||||||
handler.handleException(e);
|
handler.handleException(e);
|
||||||
context.abort();
|
context.abort();
|
||||||
}
|
}
|
||||||
|
// Reset the current user because it was changed to subscriber eperson
|
||||||
|
context.setCurrentUser(currentEperson);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
Reference in New Issue
Block a user