diff options
| author | kaniini <nenolod@gmail.com> | 2019-06-01 05:16:15 +0000 |
|---|---|---|
| committer | kaniini <nenolod@gmail.com> | 2019-06-01 05:16:15 +0000 |
| commit | b4796ccbf6302056bf6f58e30d495334b830c41e (patch) | |
| tree | fbdbde8f70a3d5fb067d22285aba058ccd5ad678 /src/services | |
| parent | 9c0ec9b794dbf225dbdc4ed1e2d657cabf25101f (diff) | |
| parent | 855566f887cb9f705f62141b929bb9a3d089099c (diff) | |
Merge branch 'feature/notification-controls' into 'develop'
wire up notification settings
See merge request pleroma/pleroma-fe!809
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/api/api.service.js | 19 | ||||
| -rw-r--r-- | src/services/backend_interactor_service/backend_interactor_service.js | 7 | ||||
| -rw-r--r-- | src/services/entity_normalizer/entity_normalizer.service.js | 5 |
3 files changed, 27 insertions, 4 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index c67eccf1..d6904d30 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -16,6 +16,7 @@ const PERMISSION_GROUP_URL = (screenName, right) => `/api/pleroma/admin/users/${ const ACTIVATION_STATUS_URL = screenName => `/api/pleroma/admin/users/${screenName}/activation_status` const ADMIN_USERS_URL = '/api/pleroma/admin/users' const SUGGESTIONS_URL = '/api/v1/suggestions' +const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings' const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites' const MASTODON_USER_NOTIFICATIONS_URL = '/api/v1/notifications' @@ -97,6 +98,21 @@ const promisedRequest = ({ method, url, payload, credentials, headers = {} }) => }) } +const updateNotificationSettings = ({credentials, settings}) => { + const form = new FormData() + + each(settings, (value, key) => { + form.append(key, value) + }) + + return fetch(NOTIFICATION_SETTINGS_URL, { + headers: authHeaders(credentials), + method: 'PUT', + body: form + }) + .then((data) => data.json()) +} + const updateAvatar = ({credentials, avatar}) => { const form = new FormData() form.append('avatar', avatar) @@ -767,7 +783,8 @@ const apiService = { markNotificationsAsSeen, fetchFavoritedByUsers, fetchRebloggedByUsers, - reportUser + reportUser, + updateNotificationSettings } export default apiService diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 639bcabc..36152429 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -87,6 +87,10 @@ const backendInteractorService = (credentials) => { return apiService.deleteUser({screen_name, credentials}) } + const updateNotificationSettings = ({settings}) => { + return apiService.updateNotificationSettings({credentials, settings}) + } + const fetchMutes = () => apiService.fetchMutes({credentials}) const muteUser = (id) => apiService.muteUser({credentials, id}) const unmuteUser = (id) => apiService.unmuteUser({credentials, id}) @@ -171,7 +175,8 @@ const backendInteractorService = (credentials) => { favorite, unfavorite, retweet, - unretweet + unretweet, + updateNotificationSettings } return backendInteractorServiceInstance diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index a2bb6e4c..1f03058d 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -134,15 +134,16 @@ export const parseUser = (data) => { if (data.pleroma) { output.follow_request_count = data.pleroma.follow_request_count - } - if (data.pleroma) { output.tags = data.pleroma.tags output.deactivated = data.pleroma.deactivated + + output.notification_settings = data.pleroma.notification_settings } output.tags = output.tags || [] output.rights = output.rights || {} + output.notification_settings = output.notification_settings || {} return output } |
