aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/mastodon/actions/accounts.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/mastodon/actions/accounts.js')
-rw-r--r--app/javascript/mastodon/actions/accounts.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/javascript/mastodon/actions/accounts.js b/app/javascript/mastodon/actions/accounts.js
index 58b636602..ce7bb6d5f 100644
--- a/app/javascript/mastodon/actions/accounts.js
+++ b/app/javascript/mastodon/actions/accounts.js
@@ -5,6 +5,10 @@ export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS';
export const ACCOUNT_FETCH_FAIL = 'ACCOUNT_FETCH_FAIL';
+export const ACCOUNT_LOOKUP_REQUEST = 'ACCOUNT_LOOKUP_REQUEST';
+export const ACCOUNT_LOOKUP_SUCCESS = 'ACCOUNT_LOOKUP_SUCCESS';
+export const ACCOUNT_LOOKUP_FAIL = 'ACCOUNT_LOOKUP_FAIL';
+
export const ACCOUNT_FOLLOW_REQUEST = 'ACCOUNT_FOLLOW_REQUEST';
export const ACCOUNT_FOLLOW_SUCCESS = 'ACCOUNT_FOLLOW_SUCCESS';
export const ACCOUNT_FOLLOW_FAIL = 'ACCOUNT_FOLLOW_FAIL';
@@ -87,6 +91,34 @@ export function fetchAccount(id) {
};
};
+export const lookupAccount = acct => (dispatch, getState) => {
+ dispatch(lookupAccountRequest(acct));
+
+ api(getState).get('/api/v1/accounts/lookup', { params: { acct } }).then(response => {
+ dispatch(fetchRelationships([response.data.id]));
+ dispatch(importFetchedAccount(response.data));
+ dispatch(lookupAccountSuccess());
+ }).catch(error => {
+ dispatch(lookupAccountFail(acct, error));
+ });
+};
+
+export const lookupAccountRequest = (acct) => ({
+ type: ACCOUNT_LOOKUP_REQUEST,
+ acct,
+});
+
+export const lookupAccountSuccess = () => ({
+ type: ACCOUNT_LOOKUP_SUCCESS,
+});
+
+export const lookupAccountFail = (acct, error) => ({
+ type: ACCOUNT_LOOKUP_FAIL,
+ acct,
+ error,
+ skipAlert: true,
+});
+
export function fetchAccountRequest(id) {
return {
type: ACCOUNT_FETCH_REQUEST,