Implementing APIs for the matches control screen + some tweaks to current discard/match feature
* Now the discard/match function call reject/authorize respectively to the follow requests (if any) this causes 404 error when there is none, but it is OK. This is a feature, not a bug. * Mastodon API improved to check callback is null * Matches pages cleared out to start from scratch
This commit is contained in:
parent
92cb0668d0
commit
6d599f1b4d
|
@ -1,20 +1,4 @@
|
|||
<DynamicPageBanner title="{intl.follows}" />
|
||||
<AccountsListPage {accountsFetcher} />
|
||||
<div id="manage-matches">
|
||||
</div>
|
||||
<script>
|
||||
import { getFollows } from '../../_api/followsAndFollowers'
|
||||
import AccountsListPage from '../../_components/AccountsListPage.html'
|
||||
import { store } from '../../_store/store'
|
||||
import DynamicPageBanner from '../../_components/DynamicPageBanner.html'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
accountId: ({ params }) => params.accountId,
|
||||
accountsFetcher: ({ $currentInstance, $accessToken, accountId }) => () => getFollows($currentInstance, $accessToken, accountId)
|
||||
},
|
||||
store: () => store,
|
||||
components: {
|
||||
AccountsListPage,
|
||||
DynamicPageBanner
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
const fediloveMastodon = {
|
||||
request: function(method, path, payload, callbk) {
|
||||
payload = payload || null;
|
||||
callbk = callbk || null;
|
||||
const ACCESS_TOKEN = window.fediloveApi.getAccessToken();
|
||||
if (ACCESS_TOKEN === undefined)
|
||||
return callbk(undefined);
|
||||
const API_URL = 'https://'+fediloveApi.getCurrentInstance()+path;
|
||||
const oReq = new XMLHttpRequest();
|
||||
oReq.addEventListener("load", function() { callbk(this.responseText); });
|
||||
oReq.addEventListener("load", function() { if (callbk) callbk(this.responseText) });
|
||||
oReq.open(method, API_URL);
|
||||
oReq.setRequestHeader('Authorization', 'Bearer '+ACCESS_TOKEN);
|
||||
oReq.send(payload);
|
||||
|
@ -27,15 +28,27 @@ const fediloveMastodon = {
|
|||
API: {
|
||||
discardAccount: function(account_id, cback) {
|
||||
fediloveMastodon.post(`/api/v1/accounts/${account_id}/block`, null, function(data) { cback() });
|
||||
fediloveMastodon.post(`/api/v1/follow_requests/${account_id}/reject`);
|
||||
},
|
||||
matchAccount: function(account_id, cback) {
|
||||
fediloveMastodon.post(`/api/v1/accounts/${account_id}/follow`, {'reblogs': true},
|
||||
function(data) { cback() }
|
||||
);
|
||||
fediloveMastodon.post(`/api/v1/accounts/${account_id}/follow`, {'reblogs': true}, function(data) { cback() });
|
||||
fediloveMastodon.post(`/api/v1/follow_requests/${account_id}/authorize`);
|
||||
},
|
||||
getRelationship: function(account_id, cback) {
|
||||
fediloveMastodon.get(`/api/v1/accounts/relationships?id=${account_id}`, null, cback);
|
||||
},
|
||||
getMyFollowing: function(cback) {
|
||||
fediloveMastodon.get(`/api/v1/accounts/${fediloveData.myAccountId}/following`, null, cback);
|
||||
},
|
||||
getMyRequestsToFollow: function(cback) {
|
||||
// to-do: find out how to list my own matches (follow requests)
|
||||
},
|
||||
getMyFollowers: function(cback) {
|
||||
fediloveMastodon.get(`/api/v1/accounts/${fediloveData.myAccountId}/followers`, null, cback);
|
||||
},
|
||||
getRequestsToFollowMe: function(cback) {
|
||||
fediloveMastodon.get('/api/v1/follow_requests', null, cback);
|
||||
},
|
||||
statusFav: function(dom, status_id) {
|
||||
var dislike = false;
|
||||
var path = `/api/v1/statuses/${status_id}/favourite`;
|
||||
|
|
Loading…
Reference in New Issue