diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-24 22:01:00 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-24 22:01:00 +0300 |
| commit | 4e339d9be34400465e336a9c589ebaea705802d1 (patch) | |
| tree | da3d62a4dcfb38ac5b8289c4a4894561d9518f73 /src/services/api/api.service.js | |
| parent | e9ad922eeb3419185e30eaf99f11eadd0a7dee44 (diff) | |
| parent | 86302128ba7c3f0389f66ebb235f51f29d45c454 (diff) | |
Merge remote-tracking branch 'origin/develop' into scrolltotop
* origin/develop: (47 commits)
Update dependency eslint-plugin-vue to v9.4.0
Update dependency opn to v5
fix notices being under the navbar, also change offset to use variable
fix modals not having proper z index
reduce indexes to be below 9999 so that develop error messages appear above
Fix react & extra buttons not styled on tab-focus
Fix popover not popping up
Fix styling on Safari
Use :focus-visible instead of :focus for focus markers
Optimize Reply badge position
Add badges to status interacting buttons
Update dependency nightwatch to v2
Update dependency eslint-plugin-n to v15.2.5
Update dependency mocha to v10
Update dependency karma-coverage to v2
Update dependency sass to v1.54.5
Update dependency karma-firefox-launcher to v2
Update dependency vue-template-compiler to v2.7.9
Pin dependencies
Refresh yarn.lock
...
Diffstat (limited to 'src/services/api/api.service.js')
| -rw-r--r-- | src/services/api/api.service.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 7b6f7d67..ce60d65a 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -50,6 +50,7 @@ const MASTODON_USER_HOME_TIMELINE_URL = '/api/v1/timelines/home' const MASTODON_STATUS_URL = id => `/api/v1/statuses/${id}` const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context` const MASTODON_USER_URL = '/api/v1/accounts' +const MASTODON_USER_LOOKUP_URL = '/api/v1/accounts/lookup' const MASTODON_USER_RELATIONSHIPS_URL = '/api/v1/accounts/relationships' const MASTODON_USER_TIMELINE_URL = id => `/api/v1/accounts/${id}/statuses` const MASTODON_LIST_URL = id => `/api/v1/lists/${id}` @@ -318,6 +319,25 @@ const fetchUser = ({ id, credentials }) => { .then((data) => parseUser(data)) } +const fetchUserByName = ({ name, credentials }) => { + return promisedRequest({ + url: MASTODON_USER_LOOKUP_URL, + credentials, + params: { acct: name } + }) + .then(data => data.id) + .catch(error => { + if (error && error.statusCode === 404) { + // Either the backend does not support lookup endpoint, + // or there is no user with such name. Fallback and treat name as id. + return name + } else { + throw error + } + }) + .then(id => fetchUser({ id, credentials })) +} + const fetchUserRelationship = ({ id, credentials }) => { const url = `${MASTODON_USER_RELATIONSHIPS_URL}/?id=${id}` return fetch(url, { headers: authHeaders(credentials) }) @@ -1481,6 +1501,7 @@ const apiService = { blockUser, unblockUser, fetchUser, + fetchUserByName, fetchUserRelationship, favorite, unfavorite, |
