From fc12b63fcc41a06ee818428640f962fbea536e1f Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Tue, 21 May 2019 23:35:40 +0300
Subject: mastoapi login works

---
 src/components/user_settings/user_settings.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 2cb8b37a..377e8295 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -44,6 +44,7 @@
                 <scope-selector
                   :showAll="true"
                   :userDefault="newDefaultScope"
+                  :initialScope="newDefaultScope"
                   :onScopeChange="changeVis"/>
               </div>
             </div>
-- 
cgit v1.2.3-70-g09d2


From 28ca504576134a8dd7b7e90488319c23f23b2300 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sat, 25 May 2019 07:01:02 +0000
Subject: wire up notification settings

---
 src/components/user_settings/user_settings.js      |  7 +++-
 src/components/user_settings/user_settings.vue     | 45 ++++++++++++++++++++++
 src/i18n/en.json                                   |  7 ++++
 src/services/api/api.service.js                    | 19 ++++++++-
 .../backend_interactor_service.js                  |  7 +++-
 .../entity_normalizer/entity_normalizer.service.js |  5 +++
 6 files changed, 87 insertions(+), 3 deletions(-)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 2418450c..ae36e5e8 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -55,7 +55,8 @@ const UserSettings = {
       changePasswordInputs: [ '', '', '' ],
       changedPassword: false,
       changePasswordError: false,
-      activeTab: 'profile'
+      activeTab: 'profile',
+      notificationSettings: this.$store.state.users.currentUser.notification_settings
     }
   },
   created () {
@@ -128,6 +129,10 @@ const UserSettings = {
             this.$store.commit('setCurrentUser', user)
           })
     },
+    updateNotificationSettings () {
+      this.$store.state.api.backendInteractor
+        .updateNotificationSettings({ settings: this.notificationSettings })
+    },
     changeVis (visibility) {
       this.newDefaultScope = visibility
     },
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 2cb8b37a..69f1b44f 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -167,6 +167,51 @@
           </div>
         </div>
 
+        <div :label="$t('settings.interactions_tab')" v-if="pleromaBackend">
+          <div class="setting-item">
+            <h2>{{$t('settings.notifications')}}</h2>
+            <ul class="setting-list">
+              <li>
+                <input type="checkbox" id="notification-setting-local" v-model="notificationSettings.local">
+                <label for="notification-setting-local">
+                {{$t('settings.notification_setting_local')}}
+                </label>
+              </li>
+              <li>
+                <input type="checkbox" id="notification-setting-remote" v-model="notificationSettings.remote">
+                <label for="notification-setting-remote">
+                {{$t('settings.notification_setting_remote')}}
+                </label>
+              </li>
+              <li>
+                <input type="checkbox" id="notification-setting-follows" v-model="notificationSettings.follows">
+                <label for="notification-setting-follows">
+                {{$t('settings.notification_setting_follows')}}
+                </label>
+              </li>
+              <li>
+                <input type="checkbox" id="notification-setting-non-follows" v-model="notificationSettings.non_follows">
+                <label for="notification-setting-non-follows">
+                {{$t('settings.notification_setting_non_follows')}}
+                </label>
+              </li>
+              <li>
+                <input type="checkbox" id="notification-setting-followers" v-model="notificationSettings.followers">
+                <label for="notification-setting-followers">
+                {{$t('settings.notification_setting_followers')}}
+                </label>
+              </li>
+              <li>
+                <input type="checkbox" id="notification-setting-non-followers" v-model="notificationSettings.non_followers">
+                <label for="notification-setting-non-followers">
+                {{$t('settings.notification_setting_non_followers')}}
+                </label>
+              </li>
+            </ul>
+            <button class="btn btn-default" @click="updateNotificationSettings">{{$t('general.submit')}}</button>
+          </div>
+        </div>
+
         <div :label="$t('settings.data_import_export_tab')" v-if="pleromaBackend">
           <div class="setting-item">
             <h2>{{$t('settings.follow_import')}}</h2>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 031c93de..2840582b 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -209,6 +209,7 @@
     "loop_video": "Loop videos",
     "loop_video_silent_only": "Loop only videos without sound (i.e. Mastodon's \"gifs\")",
     "mutes_tab": "Mutes",
+    "interactions_tab": "Interactions",
     "play_videos_in_modal": "Play videos directly in the media viewer",
     "use_contain_fit": "Don't crop the attachment in thumbnails",
     "name": "Name",
@@ -277,6 +278,12 @@
       "true": "yes"
     },
     "notifications": "Notifications",
+    "notification_setting_local": "Show notifications from local users",
+    "notification_setting_remote": "Show notifications from remote users",
+    "notification_setting_follows": "Show notifications from users you follow",
+    "notification_setting_non_follows": "Show notifications from users you do not follow",
+    "notification_setting_followers": "Show notifications from users who follow you",
+    "notification_setting_non_followers": "Show notifications from users who do not follow you",
     "enable_web_push_notifications": "Enable web push notifications",
     "style": {
       "switcher": {
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 efff23d1..baf58e9b 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -141,8 +141,13 @@ export const parseUser = (data) => {
     output.deactivated = data.pleroma.deactivated
   }
 
+  if (data.pleroma) {
+    output.notification_settings = data.pleroma.notification_settings
+  }
+
   output.tags = output.tags || []
   output.rights = output.rights || {}
+  output.notification_settings = output.notification_settings || {}
 
   return output
 }
-- 
cgit v1.2.3-70-g09d2


From 855566f887cb9f705f62141b929bb9a3d089099c Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sat, 25 May 2019 23:44:36 +0000
Subject: notification controls: redesign entirely

---
 src/components/user_settings/user_settings.vue | 72 ++++++++++++--------------
 src/i18n/en.json                               | 14 ++---
 2 files changed, 39 insertions(+), 47 deletions(-)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 69f1b44f..20b10979 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -167,47 +167,39 @@
           </div>
         </div>
 
-        <div :label="$t('settings.interactions_tab')" v-if="pleromaBackend">
+        <div :label="$t('settings.notifications')" v-if="pleromaBackend">
           <div class="setting-item">
-            <h2>{{$t('settings.notifications')}}</h2>
-            <ul class="setting-list">
-              <li>
-                <input type="checkbox" id="notification-setting-local" v-model="notificationSettings.local">
-                <label for="notification-setting-local">
-                {{$t('settings.notification_setting_local')}}
-                </label>
-              </li>
-              <li>
-                <input type="checkbox" id="notification-setting-remote" v-model="notificationSettings.remote">
-                <label for="notification-setting-remote">
-                {{$t('settings.notification_setting_remote')}}
-                </label>
-              </li>
-              <li>
-                <input type="checkbox" id="notification-setting-follows" v-model="notificationSettings.follows">
-                <label for="notification-setting-follows">
-                {{$t('settings.notification_setting_follows')}}
-                </label>
-              </li>
-              <li>
-                <input type="checkbox" id="notification-setting-non-follows" v-model="notificationSettings.non_follows">
-                <label for="notification-setting-non-follows">
-                {{$t('settings.notification_setting_non_follows')}}
-                </label>
-              </li>
-              <li>
-                <input type="checkbox" id="notification-setting-followers" v-model="notificationSettings.followers">
-                <label for="notification-setting-followers">
-                {{$t('settings.notification_setting_followers')}}
-                </label>
-              </li>
-              <li>
-                <input type="checkbox" id="notification-setting-non-followers" v-model="notificationSettings.non_followers">
-                <label for="notification-setting-non-followers">
-                {{$t('settings.notification_setting_non_followers')}}
-                </label>
-              </li>
-            </ul>
+            <div class="select-multiple">
+              <span class="label">{{$t('settings.notification_setting')}}</span>
+              <ul class="option-list">
+                <li>
+                  <input type="checkbox" id="notification-setting-follows" v-model="notificationSettings.follows">
+                  <label for="notification-setting-follows">
+                  {{$t('settings.notification_setting_follows')}}
+                  </label>
+                </li>
+                <li>
+                  <input type="checkbox" id="notification-setting-followers" v-model="notificationSettings.followers">
+                  <label for="notification-setting-followers">
+                  {{$t('settings.notification_setting_followers')}}
+                  </label>
+                </li>
+                <li>
+                  <input type="checkbox" id="notification-setting-non-follows" v-model="notificationSettings.non_follows">
+                  <label for="notification-setting-non-follows">
+                  {{$t('settings.notification_setting_non_follows')}}
+                  </label>
+                </li>
+                <li>
+                  <input type="checkbox" id="notification-setting-non-followers" v-model="notificationSettings.non_followers">
+                  <label for="notification-setting-non-followers">
+                  {{$t('settings.notification_setting_non_followers')}}
+                  </label>
+                </li>
+              </ul>
+            </div>
+            <p>{{$t('settings.notification_mutes')}}</p>
+            <p>{{$t('settings.notification_blocks')}}</p>
             <button class="btn btn-default" @click="updateNotificationSettings">{{$t('general.submit')}}</button>
           </div>
         </div>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 2840582b..2b5c5468 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -209,7 +209,6 @@
     "loop_video": "Loop videos",
     "loop_video_silent_only": "Loop only videos without sound (i.e. Mastodon's \"gifs\")",
     "mutes_tab": "Mutes",
-    "interactions_tab": "Interactions",
     "play_videos_in_modal": "Play videos directly in the media viewer",
     "use_contain_fit": "Don't crop the attachment in thumbnails",
     "name": "Name",
@@ -278,12 +277,13 @@
       "true": "yes"
     },
     "notifications": "Notifications",
-    "notification_setting_local": "Show notifications from local users",
-    "notification_setting_remote": "Show notifications from remote users",
-    "notification_setting_follows": "Show notifications from users you follow",
-    "notification_setting_non_follows": "Show notifications from users you do not follow",
-    "notification_setting_followers": "Show notifications from users who follow you",
-    "notification_setting_non_followers": "Show notifications from users who do not follow you",
+    "notification_setting": "Receive notifications from:",
+    "notification_setting_follows": "Users you follow",
+    "notification_setting_non_follows": "Users you do not follow",
+    "notification_setting_followers": "Users who follow you",
+    "notification_setting_non_followers": "Users who do not follow you",
+    "notification_mutes": "To stop receiving notifications from a specific user, use a mute.",
+    "notification_blocks": "Blocking a user stops all notifications as well as unsubscribes them.",
     "enable_web_push_notifications": "Enable web push notifications",
     "style": {
       "switcher": {
-- 
cgit v1.2.3-70-g09d2

