From bcd499c3725d620bc9d4612e04add76cf7a4e395 Mon Sep 17 00:00:00 2001
From: Hakaba Hitoyo <hakabahitoyo@example.com>
Date: Thu, 2 Aug 2018 17:57:00 +0900
Subject: [PATCH 1/8] who to follow panel uses /api/v1/suggestions

---
 .../who_to_follow_panel/who_to_follow_panel.js   | 16 ++++++----------
 src/main.js                                      | 13 +++++++++----
 static/config.json                               |  5 -----
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index 51b9f469..be9a9f31 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -7,12 +7,12 @@ function showWhoToFollow (panel, reply, aHost, aUser) {
     var user
     user = users[cn]
     var img
-    if (user.icon) {
+    if (user.avatar) {
       img = user.icon
     } else {
       img = '/images/avi.png'
     }
-    var name = user.to_id
+    var name = user.acct
     if (index === 0) {
       panel.img1 = img
       panel.name1 = name
@@ -52,17 +52,13 @@ function showWhoToFollow (panel, reply, aHost, aUser) {
 }
 
 function getWhoToFollow (panel) {
-  var user = panel.$store.state.users.currentUser.screen_name
-  if (user) {
+  var credentials = panel.$store.state.users.currentUser.credentials
+  if (credentials) {
     panel.name1 = 'Loading...'
     panel.name2 = 'Loading...'
     panel.name3 = 'Loading...'
-    var host = window.location.hostname
-    var whoToFollowProvider = panel.$store.state.config.whoToFollowProvider
-    var url
-    url = whoToFollowProvider.replace(/{{host}}/g, encodeURIComponent(host))
-    url = url.replace(/{{user}}/g, encodeURIComponent(user))
-    window.fetch(url, {mode: 'cors'}).then(function (response) {
+    var url = '/api/v1/suggestions'
+    window.fetch(url, {headers: authHeaders(credentials)}).then(function (response) {
       if (response.ok) {
         return response.json()
       } else {
diff --git a/src/main.js b/src/main.js
index bacd7f6d..3c2ac77d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -89,13 +89,10 @@ window.fetch('/api/statusnet/config.json')
 window.fetch('/static/config.json')
   .then((res) => res.json())
   .then((data) => {
-    const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel, scopeOptionsEnabled} = data
+    const {theme, background, logo, showInstanceSpecificPanel, scopeOptionsEnabled} = data
     store.dispatch('setOption', { name: 'theme', value: theme })
     store.dispatch('setOption', { name: 'background', value: background })
     store.dispatch('setOption', { name: 'logo', value: logo })
-    store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: showWhoToFollowPanel })
-    store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
-    store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
     store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
     store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
     if (data['chatDisabled']) {
@@ -144,6 +141,14 @@ window.fetch('/static/config.json')
     })
   })
 
+window.fetch('/nodeinfo/2.0.json')
+  .then((res) => res.json())
+  .then((data) => {
+    const suggestions = data.metadata.suggestions
+    store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: suggestions.enabled })
+    store.dispatch('setOption', { name: 'whoToFollowLink', value: suggestions.web })
+  })
+
 window.fetch('/static/terms-of-service.html')
   .then((res) => res.text())
   .then((html) => {
diff --git a/static/config.json b/static/config.json
index 4dacfebe..14eb5c92 100644
--- a/static/config.json
+++ b/static/config.json
@@ -5,11 +5,6 @@
   "redirectRootNoLogin": "/main/all",
   "redirectRootLogin": "/main/friends",
   "chatDisabled": false,
-  "showWhoToFollowPanel": false,
-  "whoToFollowProvider": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-osa-api.cgi?{{host}}+{{user}}",
-  "whoToFollowProviderDummy2": "https://followlink.osa-p.net/api/get_recommend.json?acct=@{{user}}@{{host}}",
-  "whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
-  "whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html",
   "showInstanceSpecificPanel": false,
   "scopeOptionsEnabled": false
 }

From 5900bccff3f09be6bfbfa4a891c91ee043e3a9f0 Mon Sep 17 00:00:00 2001
From: Hakaba Hitoyo <hakabahitoyo@example.com>
Date: Thu, 2 Aug 2018 18:34:12 +0900
Subject: [PATCH 2/8] debug

---
 .../who_to_follow_panel.js                    | 19 +++++++------------
 src/services/api/api.service.js               | 10 +++++++++-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index be9a9f31..5e85b95d 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -1,4 +1,6 @@
-function showWhoToFollow (panel, reply, aHost, aUser) {
+import apiService from '../../services/api/api.service.js'
+
+function showWhoToFollow (panel, reply) {
   var users = reply.ids
   var cn
   var index = 0
@@ -58,17 +60,10 @@ function getWhoToFollow (panel) {
     panel.name2 = 'Loading...'
     panel.name3 = 'Loading...'
     var url = '/api/v1/suggestions'
-    window.fetch(url, {headers: authHeaders(credentials)}).then(function (response) {
-      if (response.ok) {
-        return response.json()
-      } else {
-        panel.name1 = ''
-        panel.name2 = ''
-        panel.name3 = ''
-      }
-    }).then(function (reply) {
-      showWhoToFollow(panel, reply, host, user)
-    })
+    apiService.suggestions ({credentials: credentials})
+      .then ((reply) => {
+        showWhoToFollow(panel, reply)
+      })
   }
 }
 
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index adf598b7..d07e43c6 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -36,6 +36,7 @@ const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
 const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests'
 const APPROVE_USER_URL = '/api/pleroma/friendships/approve'
 const DENY_USER_URL = '/api/pleroma/friendships/deny'
+const SUGGESTIONS_URL = '/api/v1/suggestions'
 
 import { each, map } from 'lodash'
 import 'whatwg-fetch'
@@ -448,6 +449,12 @@ const fetchMutes = ({credentials}) => {
   }).then((data) => data.json())
 }
 
+const suggestions = ({credentials}) => {
+  return fetch(SUGGESTIONS_URL, {
+    headers: authHeaders(credentials)
+  }).then((data) => data.json())
+}
+
 const apiService = {
   verifyCredentials,
   fetchTimeline,
@@ -481,7 +488,8 @@ const apiService = {
   changePassword,
   fetchFollowRequests,
   approveUser,
-  denyUser
+  denyUser,
+  suggestions
 }
 
 export default apiService

From 19e310fc670d329896829d25d25d59a16b425ed1 Mon Sep 17 00:00:00 2001
From: Hakaba Hitoyo <hakabahitoyo@example.com>
Date: Thu, 2 Aug 2018 18:38:43 +0900
Subject: [PATCH 3/8] lint

---
 src/components/who_to_follow_panel/who_to_follow_panel.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index 5e85b95d..5b7f6b94 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -59,9 +59,8 @@ function getWhoToFollow (panel) {
     panel.name1 = 'Loading...'
     panel.name2 = 'Loading...'
     panel.name3 = 'Loading...'
-    var url = '/api/v1/suggestions'
-    apiService.suggestions ({credentials: credentials})
-      .then ((reply) => {
+    apiService.suggestions({credentials: credentials})
+      .then((reply) => {
         showWhoToFollow(panel, reply)
       })
   }

From 5e47c59615a1ebe7c42a43eea2e93b814742e9e9 Mon Sep 17 00:00:00 2001
From: hakabahitoyo <hakabahitoyo@example.com>
Date: Thu, 2 Aug 2018 19:16:48 +0900
Subject: [PATCH 4/8] debug

---
 src/components/who_to_follow_panel/who_to_follow_panel.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index 5b7f6b94..d7626dd4 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -1,7 +1,7 @@
 import apiService from '../../services/api/api.service.js'
 
 function showWhoToFollow (panel, reply) {
-  var users = reply.ids
+  var users = reply
   var cn
   var index = 0
   var random = Math.floor(Math.random() * 10)
@@ -10,7 +10,7 @@ function showWhoToFollow (panel, reply) {
     user = users[cn]
     var img
     if (user.avatar) {
-      img = user.icon
+      img = user.avatar
     } else {
       img = '/images/avi.png'
     }

From bebd9c5ec8224c4be5b94e3cccf763f1a3489910 Mon Sep 17 00:00:00 2001
From: tsukada-ecsec <tsukada@ecsec.org>
Date: Wed, 22 Aug 2018 11:35:56 +0900
Subject: [PATCH 5/8] revert

---
 static/config.json | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/static/config.json b/static/config.json
index 14eb5c92..62b85aae 100644
--- a/static/config.json
+++ b/static/config.json
@@ -5,6 +5,12 @@
   "redirectRootNoLogin": "/main/all",
   "redirectRootLogin": "/main/friends",
   "chatDisabled": false,
+  "showWhoToFollowPanel": false,
+  "whoToFollowProvider": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-osa-api.cgi?{{host}}+{{user}}",
+  "whoToFollowProviderDummy2": "https://followlink.osa-p.net/api/get_recommend.json?acct=@{{user}}@{{host}}",
+  "whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
+  "whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html",
   "showInstanceSpecificPanel": false,
-  "scopeOptionsEnabled": false
+  "scopeOptionsEnabled": false,
+  "collapseMessageWithSubject": false
 }

From 41256045f2f11bdcb9874f08288a66a9c47aa28a Mon Sep 17 00:00:00 2001
From: tsukada-ecsec <tsukada@ecsec.org>
Date: Wed, 22 Aug 2018 11:38:04 +0900
Subject: [PATCH 6/8] revert main.js

---
 src/main.js | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/main.js b/src/main.js
index 3c2ac77d..06f8a6ec 100644
--- a/src/main.js
+++ b/src/main.js
@@ -45,6 +45,7 @@ Vue.use(VueChatScroll)
 
 const persistedStateOptions = {
   paths: [
+    'config.collapseMessageWithSubject',
     'config.hideAttachments',
     'config.hideAttachmentsInConv',
     'config.hideNsfw',
@@ -53,6 +54,11 @@ const persistedStateOptions = {
     'config.streaming',
     'config.muteWords',
     'config.customTheme',
+    'config.highlight',
+    'config.loopVideo',
+    'config.loopVideoSilentOnly',
+    'config.pauseOnUnfocused',
+    'config.stopGifs',
     'users.lastLoginName'
   ]
 }
@@ -79,22 +85,27 @@ const i18n = new VueI18n({
 window.fetch('/api/statusnet/config.json')
   .then((res) => res.json())
   .then((data) => {
-    const {name, closed: registrationClosed, textlimit} = data.site
+    const {name, closed: registrationClosed, textlimit, server} = data.site
 
     store.dispatch('setOption', { name: 'name', value: name })
     store.dispatch('setOption', { name: 'registrationOpen', value: (registrationClosed === '0') })
     store.dispatch('setOption', { name: 'textlimit', value: parseInt(textlimit) })
+    store.dispatch('setOption', { name: 'server', value: server })
   })
 
 window.fetch('/static/config.json')
   .then((res) => res.json())
   .then((data) => {
-    const {theme, background, logo, showInstanceSpecificPanel, scopeOptionsEnabled} = data
+    const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel, scopeOptionsEnabled, collapseMessageWithSubject} = data
     store.dispatch('setOption', { name: 'theme', value: theme })
     store.dispatch('setOption', { name: 'background', value: background })
     store.dispatch('setOption', { name: 'logo', value: logo })
+    store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: showWhoToFollowPanel })
+    store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
+    store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
     store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
     store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
+    store.dispatch('setOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject })
     if (data['chatDisabled']) {
       store.dispatch('disableChat')
     }
@@ -116,6 +127,7 @@ window.fetch('/static/config.json')
       { name: 'mentions', path: '/:username/mentions', component: Mentions },
       { name: 'settings', path: '/settings', component: Settings },
       { name: 'registration', path: '/registration', component: Registration },
+      { name: 'registration', path: '/registration/:token', component: Registration },
       { name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
       { name: 'user-settings', path: '/user-settings', component: UserSettings }
     ]
@@ -141,14 +153,6 @@ window.fetch('/static/config.json')
     })
   })
 
-window.fetch('/nodeinfo/2.0.json')
-  .then((res) => res.json())
-  .then((data) => {
-    const suggestions = data.metadata.suggestions
-    store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: suggestions.enabled })
-    store.dispatch('setOption', { name: 'whoToFollowLink', value: suggestions.web })
-  })
-
 window.fetch('/static/terms-of-service.html')
   .then((res) => res.text())
   .then((html) => {

From 54166c3ad3bd3c9377d7788b84733c19d16732ad Mon Sep 17 00:00:00 2001
From: tsukada-ecsec <tsukada@ecsec.org>
Date: Wed, 22 Aug 2018 11:47:36 +0900
Subject: [PATCH 7/8] update settings

---
 src/App.js                                                | 2 +-
 src/App.vue                                               | 2 +-
 src/components/who_to_follow_panel/who_to_follow_panel.js | 4 ++--
 src/main.js                                               | 8 ++++++++
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/App.js b/src/App.js
index a052e058..39c97a80 100644
--- a/src/App.js
+++ b/src/App.js
@@ -29,7 +29,7 @@ export default {
     style () { return { 'background-image': `url(${this.background})` } },
     sitename () { return this.$store.state.config.name },
     chat () { return this.$store.state.chat.channel.state === 'joined' },
-    showWhoToFollowPanel () { return this.$store.state.config.showWhoToFollowPanel },
+    suggestionsEnabled () { return this.$store.state.config.suggestionsEnabled },
     showInstanceSpecificPanel () { return this.$store.state.config.showInstanceSpecificPanel }
   },
   methods: {
diff --git a/src/App.vue b/src/App.vue
index 923d411b..71e90289 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -24,7 +24,7 @@
               <user-panel></user-panel>
               <nav-panel></nav-panel>
               <instance-specific-panel v-if="showInstanceSpecificPanel"></instance-specific-panel>
-              <who-to-follow-panel v-if="currentUser && showWhoToFollowPanel"></who-to-follow-panel>
+              <who-to-follow-panel v-if="currentUser && suggestionsEnabled"></who-to-follow-panel>
               <notifications v-if="currentUser"></notifications>
             </div>
           </div>
diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index d7626dd4..70b35980 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -85,9 +85,9 @@ const WhoToFollowPanel = {
     moreUrl: function () {
       var host = window.location.hostname
       var user = this.user
-      var whoToFollowLink = this.$store.state.config.whoToFollowLink
+      var suggestionsWeb = this.$store.state.config.suggestionsWeb
       var url
-      url = whoToFollowLink.replace(/{{host}}/g, encodeURIComponent(host))
+      url = suggestionsWeb.replace(/{{host}}/g, encodeURIComponent(host))
       url = url.replace(/{{user}}/g, encodeURIComponent(user))
       return url
     },
diff --git a/src/main.js b/src/main.js
index 06f8a6ec..4124214d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -192,3 +192,11 @@ window.fetch('/instance/panel.html')
     store.dispatch('setOption', { name: 'instanceSpecificPanelContent', value: html })
   })
 
+window.fetch('/nodeinfo/2.0.json')
+  .then((res) => res.json())
+  .then((data) => {
+    const suggestions = data.metadata.suggestions
+    store.dispatch('setOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
+    store.dispatch('setOption', { name: 'suggestionsWeb', value: suggestions.web })
+  })
+

From 0647c1bb720144b3d9e3d7943129d0d67d176ab0 Mon Sep 17 00:00:00 2001
From: tsukada-ecsec <tsukada@ecsec.org>
Date: Wed, 22 Aug 2018 15:15:15 +0900
Subject: [PATCH 8/8] debug

---
 src/components/who_to_follow_panel/who_to_follow_panel.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index 70b35980..6766e561 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -91,20 +91,20 @@ const WhoToFollowPanel = {
       url = url.replace(/{{user}}/g, encodeURIComponent(user))
       return url
     },
-    showWhoToFollowPanel () {
-      return this.$store.state.config.showWhoToFollowPanel
+    suggestionsEnabled () {
+      return this.$store.state.config.suggestionsEnabled
     }
   },
   watch: {
     user: function (user, oldUser) {
-      if (this.showWhoToFollowPanel) {
+      if (this.suggestionsEnabled) {
         getWhoToFollow(this)
       }
     }
   },
   mounted:
     function () {
-      if (this.showWhoToFollowPanel) {
+      if (this.suggestionsEnabled) {
         getWhoToFollow(this)
       }
     }