who to follow panel uses /api/v1/suggestions

This commit is contained in:
Hakaba Hitoyo 2018-08-02 17:57:00 +09:00
parent 32fd108e97
commit bcd499c372
3 changed files with 15 additions and 19 deletions

View File

@ -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 {

View File

@ -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) => {

View File

@ -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
}