Package org.ametys.plugins.mobileapp
Class UserPreferencesHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.mobileapp.UserPreferencesHelper
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
Helper to store/retreive conf per user
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProviderThe current user providerprotected JSONUtilsJSON Utilsprotected UserPreferencesManagerUser Preferences Managerstatic final StringThe avalon role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNotificationSettings(String pushToken, UserIdentity user) Get the notification settings for a tokenGet all notification tokens for current userGet all notification tokens a usergetUserImpactedTokens(UserIdentity user, Set<String> feedIds, Site site) Get the list of impacted tokens for each feeds, for a usergetUserImpactedTokens(UserIdentity user, Project project, String eventType) Get the list of impacted tokens for each feeds, for a uservoidRemove all the notification tokens for a uservoidremoveNotificationToken(String pushToken) Removes a notification token for the current uservoidremoveNotificationToken(String pushToken, UserIdentity user) Removes a notification token for a uservoidservice(ServiceManager manager) voidsetNotificationSettings(String pushToken, boolean enabled, boolean allFeeds, List<String> feeds, boolean allProjects, List<String> projects, boolean allTypes, List<String> types, String lang) Save the notification settings for the current uservoidsetNotificationSettings(String pushToken, boolean enabled, boolean allFeeds, List<String> feeds, boolean allProjects, List<String> projects, boolean allTypes, List<String> types, String lang, UserIdentity user) Save the notification settings for a userMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role. -
_userPreferencesManager
User Preferences Manager -
_currentUserProvider
The current user provider -
_jsonUtils
JSON Utils
-
-
Constructor Details
-
UserPreferencesHelper
public UserPreferencesHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getUserImpactedTokens
public Map<String,Set<String>> getUserImpactedTokens(UserIdentity user, Set<String> feedIds, Site site) Get the list of impacted tokens for each feeds, for a user- Parameters:
user- user to checkfeedIds- list of feeds to checksite- the site for the validated content- Returns:
- a map with a Set of tokens for each feedId
-
getUserImpactedTokens
public Map<String,Set<String>> getUserImpactedTokens(UserIdentity user, Project project, String eventType) Get the list of impacted tokens for each feeds, for a user- Parameters:
user- user to checkproject- test if a notification should be sent for this projecteventType- test if a notification should be sent for this event type- Returns:
- a map with a the set of tokens impacted for each languages
-
getNotificationTokens
Get all notification tokens for current user- Returns:
- the list of notification tokens
-
getNotificationTokens
Get all notification tokens a user- Parameters:
user- the user impacted- Returns:
- the list of notification tokens
-
removeNotificationToken
Removes a notification token for the current user- Parameters:
pushToken- the token to remove
-
removeNotificationToken
Removes a notification token for a user- Parameters:
pushToken- the token to removeuser- the user impacted
-
removeAllNotificationTokens
Remove all the notification tokens for a user- Parameters:
user- the user impacted
-
setNotificationSettings
public void setNotificationSettings(String pushToken, boolean enabled, boolean allFeeds, List<String> feeds, boolean allProjects, List<String> projects, boolean allTypes, List<String> types, String lang) Save the notification settings for the current user- Parameters:
pushToken- the token to impactenabled- if notifications are enabledallFeeds- if all feeds are allowed to be notifiedfeeds- list of feeds ID for notificationsallProjects- if all projects are allowed to be notifiedprojects- list of project ID for notificationsallTypes- if all types are allowed to be notifiedtypes- list of notifications types for notifications in projectslang- lang of this device
-
setNotificationSettings
public void setNotificationSettings(String pushToken, boolean enabled, boolean allFeeds, List<String> feeds, boolean allProjects, List<String> projects, boolean allTypes, List<String> types, String lang, UserIdentity user) Save the notification settings for a user- Parameters:
pushToken- token impacted by this settingsenabled- if notifications are enabledallFeeds- if all feeds are allowed to be notifiedfeeds- list of feeds ID for notificationsallProjects- if all projects are allowed to be notifiedprojects- list of project ID for notificationsallTypes- if all types are allowed to be notifiedtypes- list of notifications types for notifications in projectslang- lang of this deviceuser- the user impacted
-
getNotificationSettings
Get the notification settings for a token- Parameters:
pushToken- the token to readuser- the user impacted- Returns:
- a map containing feeds, projects and types as Set<String>, and epochDay as the last modification date
-