From bcd499c3725d620bc9d4612e04add76cf7a4e395 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Thu, 2 Aug 2018 17:57:00 +0900 Subject: [PATCH] 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 }