From 2471b71aabdafc0e680795645cb48f89636974a8 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Sat, 5 May 2018 00:53:40 +0900 Subject: [PATCH] osa-compatible who to follow provider --- .../who_to_follow_panel.js | 85 ++++++++----------- static/config.json | 4 +- 2 files changed, 38 insertions(+), 51 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 e6638fca..bbbb7f4c 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,59 +1,48 @@ -function showWhoToFollow (panel, users, aHost, aUser) { +function showWhoToFollow (panel, reply, aHost, aUser) { + var users = reply.ids var cn var index = 0 var random = Math.floor(Math.random() * 10) for (cn = random; cn < users.length; cn = cn + 10) { var user user = users[cn] - var host - host = user.host - var username - if (user.username) { - username = user.username - } else { - username = user.user - } var img - if (user.avatar) { - img = user.avatar + if (user.icon) { + img = user.icon } else { img = '/images/avi.png' } - var name = username + '@' + host - if ((!user.following) && - (!user.blacklisted) && - (!(host === aHost && username === aUser))) { - if (index === 0) { - panel.img1 = img - panel.name1 = name - panel.$store.state.api.backendInteractor.externalProfile(name) - .then((externalUser) => { - if (!externalUser.error) { - panel.$store.commit('addNewUsers', [externalUser]) - panel.id1 = externalUser.id - } - }) - } else if (index === 1) { - panel.img2 = img - panel.name2 = name - panel.$store.state.api.backendInteractor.externalProfile(name) - .then((externalUser) => { - if (!externalUser.error) { - panel.$store.commit('addNewUsers', [externalUser]) - panel.id2 = externalUser.id - } - }) - } else if (index === 2) { - panel.img3 = img - panel.name3 = name - panel.$store.state.api.backendInteractor.externalProfile(name) - .then((externalUser) => { - if (!externalUser.error) { - panel.$store.commit('addNewUsers', [externalUser]) - panel.id3 = externalUser.id - } - }) - } + var name = user.to_id + if (index === 0) { + panel.img1 = img + panel.name1 = name + panel.$store.state.api.backendInteractor.externalProfile(name) + .then((externalUser) => { + if (!externalUser.error) { + panel.$store.commit('addNewUsers', [externalUser]) + panel.id1 = externalUser.id + } + }) + } else if (index === 1) { + panel.img2 = img + panel.name2 = name + panel.$store.state.api.backendInteractor.externalProfile(name) + .then((externalUser) => { + if (!externalUser.error) { + panel.$store.commit('addNewUsers', [externalUser]) + panel.id2 = externalUser.id + } + }) + } else if (index === 2) { + panel.img3 = img + panel.name3 = name + panel.$store.state.api.backendInteractor.externalProfile(name) + .then((externalUser) => { + if (!externalUser.error) { + panel.$store.commit('addNewUsers', [externalUser]) + panel.id3 = externalUser.id + } + }) index = index + 1 if (index > 2) { break @@ -81,8 +70,8 @@ function getWhoToFollow (panel) { panel.name2 = '' panel.name3 = '' } - }).then(function (users) { - showWhoToFollow(panel, users, host, user) + }).then(function (reply) { + showWhoToFollow(panel, reply, host, user) }) } } diff --git a/static/config.json b/static/config.json index 08664927..9cdb22d5 100644 --- a/static/config.json +++ b/static/config.json @@ -6,11 +6,9 @@ "redirectRootLogin": "/main/friends", "chatDisabled": false, "showWhoToFollowPanel": false, - "whoToFollowProvider": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-simple-api.cgi?{{host}}+{{user}}", - "whoToFollowProviderDummy1": "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-osa-api.cgi?{{host}}+{{user}}", + "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}}", - "whoToFollowLinkDummy1": "https://vinayaka.distsn.org/?{{host}}+{{user}}", "whoToFollowLinkDummy2": "https://followlink.osa-p.net/recommend.html", "showInstanceSpecificPanel": false }