Class AbstractNotifyMentionsObserver<T extends AmetysObject>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.repository.comment.contributor.AbstractNotifyMentionsObserver<T>
- Type Parameters:
T
- type of theAmetysObject
- All Implemented Interfaces:
AsyncObserver
,Observer
,LogEnabled
,Component
,Serviceable
- Direct Known Subclasses:
NotifyContentMentionsObserver
public abstract class AbstractNotifyMentionsObserver<T extends AmetysObject>
extends AbstractLogEnabled
implements Component, Serviceable, AsyncObserver
Abstract observer to send mails to mentioned users in contributor comments of
AmetysObject
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Link to the ametys object -
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected I18nUtils
The i18n utils.protected Map<UserIdentity,
User> Cache for resolved usersprotected AmetysObjectResolver
The ametys object resolverprotected UserManager
The user managerFields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_getAmetysObjectTitle
(T ametysObject) Retrieves the string to use to display the ametys object in the emailprotected String
_getCommentContentWithReplacedMentions
(String commentContent, UserIdentity recipient, Collection<UserIdentity> allMentionedUsers) Retrieves the given comment content with mentioned replaced by the version to display in notificationprotected abstract String
_getLanguage
(T ametysObject) Retrieves the language to use in sent mailsprotected abstract AbstractNotifyMentionsObserver.LinkToAmetysObject
_getLinkToAmetysObject
(T ametysObject) Retrieves the notification mail's body link to ametys objectprotected I18nizableText
_getMailSubject
(T ametysObject) Retrieves the notification mail's subject_getUserFromIdentity
(UserIdentity userIdentity) Retrieves theUser
object from the givenUserIdentity
int
getPriority
(Event event) Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.void
Observes an event.void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.core.observation.AsyncObserver
parallelizable
-
Field Details
-
_resolver
The ametys object resolver -
_userManager
The user manager -
_currentUserProvider
The current user provider -
_i18nUtils
The i18n utils. -
_resolvedUsers
Cache for resolved users
-
-
Constructor Details
-
AbstractNotifyMentionsObserver
public AbstractNotifyMentionsObserver()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getPriority
Description copied from interface:Observer
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriority
in interfaceObserver
- Parameters:
event
- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
Description copied from interface:Observer
Observes an event.- Specified by:
observe
in interfaceObserver
- Parameters:
event
- the event.transientVars
- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception
- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
_getMailSubject
Retrieves the notification mail's subject- Parameters:
ametysObject
- the ametys object- Returns:
- the notification mail's subject
-
_getAmetysObjectTitle
Retrieves the string to use to display the ametys object in the email- Parameters:
ametysObject
- the ametysObject- Returns:
- the ametys object's title
-
_getLinkToAmetysObject
protected abstract AbstractNotifyMentionsObserver.LinkToAmetysObject _getLinkToAmetysObject(T ametysObject) Retrieves the notification mail's body link to ametys object- Parameters:
ametysObject
- the ametys object- Returns:
- the notification mail's body link
-
_getCommentContentWithReplacedMentions
protected String _getCommentContentWithReplacedMentions(String commentContent, UserIdentity recipient, Collection<UserIdentity> allMentionedUsers) Retrieves the given comment content with mentioned replaced by the version to display in notification- Parameters:
commentContent
- the original comment contentrecipient
- the recipient user identityallMentionedUsers
- all the users mentioned in the comment- Returns:
- the content with replaced mentioned
-
_getUserFromIdentity
Retrieves theUser
object from the givenUserIdentity
- Parameters:
userIdentity
- the user identity- Returns:
- the corresponding
User
object, or an empty optional if the user does not exists
-
_getLanguage
Retrieves the language to use in sent mails- Parameters:
ametysObject
- the ametys object- Returns:
- the language to use in sent mails
-