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
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected JSONUtils
JSON Utilsprotected UserPreferencesManager
User Preferences Managerstatic final String
The avalon role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addNotificationToken
(String pushToken, String lang) Add a notification token for the current uservoid
addNotificationToken
(String pushToken, String lang, UserIdentity user) Add a notification token for a userAdd a token in a map, with the feeds impactedgetNotificationSettings
(String pushToken, UserIdentity user) Get the notification settings for a tokenGet all notification tokens for current userGet all notification tokens a usergetUserImpactedTokens
(UserIdentity user, List<String> feedIds) 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 uservoid
Remove all the notification tokens for a uservoid
removeNotificationToken
(String pushToken) Removes a notification token for the current uservoid
removeNotificationToken
(String pushToken, UserIdentity user) Removes a notification token for a uservoid
service
(ServiceManager manager) void
setNotificationSettings
(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang) Save the notification settings for the current uservoid
setNotificationSettings
(String pushToken, List<String> feeds, List<String> projects, 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:
service
in interfaceServiceable
- Throws:
ServiceException
-
getUserImpactedTokens
Get the list of impacted tokens for each feeds, for a user- Parameters:
user
- user to checkfeedIds
- list of feeds to check- 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
-
addTokenToMap
protected Map<String,Set<String>> addTokenToMap(String token, List<String> feedIds, Map<String, Set<String>> existingMap) Add a token in a map, with the feeds impacted- Parameters:
token
- the token to testfeedIds
- the feeds impactedexistingMap
- the existing map of feed -> set of tokens- Returns:
- the map, with the token added
-
addNotificationToken
Add a notification token for the current user- Parameters:
pushToken
- the token to storelang
- lang of this device
-
addNotificationToken
Add a notification token for a user- Parameters:
pushToken
- the token to storelang
- lang of this deviceuser
- the user impacted
-
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, List<String> feeds, List<String> projects, List<String> types, String lang) Save the notification settings for the current user- Parameters:
pushToken
- the token to impactfeeds
- list of feeds ID for notificationsprojects
- list of project ID for notificationstypes
- list of notifications types for notifications in projectslang
- lang of this device
-
setNotificationSettings
public void setNotificationSettings(String pushToken, List<String> feeds, List<String> projects, List<String> types, String lang, UserIdentity user) Save the notification settings for a user- Parameters:
pushToken
- token impacted by this settingsfeeds
- list of feeds ID for notificationsprojects
- list of project ID for notificationstypes
- 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
-