Class AbstractNotifyMentionsObserver<T extends AmetysObject>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.repository.mentions.AbstractNotifyMentionsObserver<T>
- Type Parameters:
T- type of theAmetysObject
- All Implemented Interfaces:
AsyncObserver,Observer,LogEnabled,Prioritizable,Supporter<Event>,Component,Serviceable
- Direct Known Subclasses:
AbstractCommentNotifyMentionsObserver,NotifyThreadMentionsObserver
public abstract class AbstractNotifyMentionsObserver<T extends AmetysObject>
extends AbstractLogEnabled
implements Component, Serviceable, AsyncObserver
Abstract observer to send mails to mentioned users in
AmetysObject-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordLink to the ametys objectstatic final recordA record to get all information of the mentionable object -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProviderThe current user providerprotected I18nUtilsThe i18n utils.protected MentionUtilsThe mention utilsprotected Map<UserIdentity, User> Cache for resolved usersprotected AmetysObjectResolverThe ametys object resolverprotected UserLanguagesManagerThe user languages managerprotected UserManagerThe user managerFields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_canSendMailToMentionedUser(T ametysObject, User authorIdentity, UserIdentity mentionedUserIdentity) trueif we can send a mail to the mentioned userprotected String_createBody(User user, I18nizableText message, AbstractNotifyMentionsObserver.MentionableObject mentionableObject, String language) create a mail body with argumentsprotected abstract I18nizableText_getMailMessage(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Retrieves the notification mail's subjectprotected abstract I18nizableTextGet the type of message to display before the messageprotected abstract I18nizableText_getMailSubject(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Retrieves the notification mail's subjectprotected abstract I18nizableText_getMailTitle(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Get the title of the mail bodyprotected abstract AbstractNotifyMentionsObserver.MentionableObject_getMentionableObjectFromArguments(Map<String, Object> arguments) Get all information of the mentionable object from the argumentsprotected voidSend mail to the given userprotected void_sendMailToMentionedUsers(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Send mail to all mentioned users in the mentionable objectprotected abstract String_transformSyntaxTextToReadableTextWithColors(String syntaxText, UserIdentity recipient) Transform syntax text to readable text with colors according to whether the recipient is the one being tagged or notintGet the priority for the component.protected StandardMailBodyHelper.MailBodyBuilderGet a standard mail body helpervoidObserves an event.voidservice(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 -
_mentionUtils
The mention utils -
_userLanguagesManager
The user languages manager
-
-
Constructor Details
-
AbstractNotifyMentionsObserver
public AbstractNotifyMentionsObserver()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getPriority
Description copied from interface:PrioritizableGet the priority for the component. On components usingPrioritizableinterface, each implementation define the order. In most cases, less is the number, more prior is the component.- Specified by:
getPriorityin interfacePrioritizable- Returns:
- the priority
-
observe
Description copied from interface:ObserverObserves an event.- Specified by:
observein 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.
-
_sendMailToMentionedUsers
protected void _sendMailToMentionedUsers(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Send mail to all mentioned users in the mentionable object- Parameters:
mentionableObject- the mentionable object
-
_createBody
protected String _createBody(User user, I18nizableText message, AbstractNotifyMentionsObserver.MentionableObject mentionableObject, String language) create a mail body with arguments- Parameters:
user- the usermessage- the messagementionableObject- the objectlanguage- the language to use- Returns:
- the mail body
-
getStandardMailBodyHelper
Get a standard mail body helper- Returns:
- the standard mail body helper
-
_getMailMessageType
Get the type of message to display before the message- Returns:
- the message type
-
_getMailTitle
protected abstract I18nizableText _getMailTitle(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Get the title of the mail body- Parameters:
mentionableObject- the mentionable object- Returns:
- the mail title
-
_transformSyntaxTextToReadableTextWithColors
protected abstract String _transformSyntaxTextToReadableTextWithColors(String syntaxText, UserIdentity recipient) Transform syntax text to readable text with colors according to whether the recipient is the one being tagged or not- Parameters:
syntaxText- the syntax textrecipient- the recipient- Returns:
- the readable text
-
_canSendMailToMentionedUser
protected boolean _canSendMailToMentionedUser(T ametysObject, User authorIdentity, UserIdentity mentionedUserIdentity) trueif we can send a mail to the mentioned user- Parameters:
ametysObject- the ametys objectauthorIdentity- the authormentionedUserIdentity- the mentioned user- Returns:
trueif we can send a mail to the mentioned user
-
_getMailSubject
protected abstract I18nizableText _getMailSubject(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Retrieves the notification mail's subject- Parameters:
mentionableObject- the mentionable object- Returns:
- the notification mail's subject
-
_getMailMessage
protected abstract I18nizableText _getMailMessage(AbstractNotifyMentionsObserver.MentionableObject mentionableObject) Retrieves the notification mail's subject- Parameters:
mentionableObject- the mentionable object- Returns:
- the notification mail's subject
-
_getMentionableObjectFromArguments
protected abstract AbstractNotifyMentionsObserver.MentionableObject _getMentionableObjectFromArguments(Map<String, Object> arguments) throws ExceptionGet all information of the mentionable object from the arguments- Parameters:
arguments- the arguments map- Returns:
- the mentionable object
- Throws:
Exception- if an error occurs.
-
_sendMail
Send mail to the given user- Parameters:
user- the usersubject- the mail subjectbody- the mail body
-