osa-compatible who to follow provider

This commit is contained in:
Hakaba Hitoyo 2018-05-05 00:53:40 +09:00
parent 0691af1367
commit 2471b71aab
2 changed files with 38 additions and 51 deletions

View File

@ -1,59 +1,48 @@
function showWhoToFollow (panel, users, aHost, aUser) { function showWhoToFollow (panel, reply, aHost, aUser) {
var users = reply.ids
var cn var cn
var index = 0 var index = 0
var random = Math.floor(Math.random() * 10) var random = Math.floor(Math.random() * 10)
for (cn = random; cn < users.length; cn = cn + 10) { for (cn = random; cn < users.length; cn = cn + 10) {
var user var user
user = users[cn] user = users[cn]
var host
host = user.host
var username
if (user.username) {
username = user.username
} else {
username = user.user
}
var img var img
if (user.avatar) { if (user.icon) {
img = user.avatar img = user.icon
} else { } else {
img = '/images/avi.png' img = '/images/avi.png'
} }
var name = username + '@' + host var name = user.to_id
if ((!user.following) && if (index === 0) {
(!user.blacklisted) && panel.img1 = img
(!(host === aHost && username === aUser))) { panel.name1 = name
if (index === 0) { panel.$store.state.api.backendInteractor.externalProfile(name)
panel.img1 = img .then((externalUser) => {
panel.name1 = name if (!externalUser.error) {
panel.$store.state.api.backendInteractor.externalProfile(name) panel.$store.commit('addNewUsers', [externalUser])
.then((externalUser) => { panel.id1 = externalUser.id
if (!externalUser.error) { }
panel.$store.commit('addNewUsers', [externalUser]) })
panel.id1 = externalUser.id } else if (index === 1) {
} panel.img2 = img
}) panel.name2 = name
} else if (index === 1) { panel.$store.state.api.backendInteractor.externalProfile(name)
panel.img2 = img .then((externalUser) => {
panel.name2 = name if (!externalUser.error) {
panel.$store.state.api.backendInteractor.externalProfile(name) panel.$store.commit('addNewUsers', [externalUser])
.then((externalUser) => { panel.id2 = externalUser.id
if (!externalUser.error) { }
panel.$store.commit('addNewUsers', [externalUser]) })
panel.id2 = externalUser.id } else if (index === 2) {
} panel.img3 = img
}) panel.name3 = name
} else if (index === 2) { panel.$store.state.api.backendInteractor.externalProfile(name)
panel.img3 = img .then((externalUser) => {
panel.name3 = name if (!externalUser.error) {
panel.$store.state.api.backendInteractor.externalProfile(name) panel.$store.commit('addNewUsers', [externalUser])
.then((externalUser) => { panel.id3 = externalUser.id
if (!externalUser.error) { }
panel.$store.commit('addNewUsers', [externalUser]) })
panel.id3 = externalUser.id
}
})
}
index = index + 1 index = index + 1
if (index > 2) { if (index > 2) {
break break
@ -81,8 +70,8 @@ function getWhoToFollow (panel) {
panel.name2 = '' panel.name2 = ''
panel.name3 = '' panel.name3 = ''
} }
}).then(function (users) { }).then(function (reply) {
showWhoToFollow(panel, users, host, user) showWhoToFollow(panel, reply, host, user)
}) })
} }
} }

View File

@ -6,11 +6,9 @@
"redirectRootLogin": "/main/friends", "redirectRootLogin": "/main/friends",
"chatDisabled": false, "chatDisabled": false,
"showWhoToFollowPanel": false, "showWhoToFollowPanel": false,
"whoToFollowProvider": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-simple-api.cgi?{{host}}+{{user}}", "whoToFollowProvider": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-osa-api.cgi?{{host}}+{{user}}",
"whoToFollowProviderDummy1": "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}}", "whoToFollowProviderDummy2": "https://followlink.osa-p.net/api/get_recommend.json?acct=@{{user}}@{{host}}",
"whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}", "whoToFollowLink": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
"whoToFollowLinkDummy1": "https://vinayaka.distsn.org/?{{host}}+{{user}}",
"whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html", "whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html",
"showInstanceSpecificPanel": false "showInstanceSpecificPanel": false
} }