forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kb_migration' into kb_migration_development
- Loading branch information
Showing
26 changed files
with
406 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createAppAsyncThunk } from 'mastodon/store/typed_functions'; | ||
|
||
import api from '../api'; | ||
|
||
export const submitAccountNote = createAppAsyncThunk( | ||
'account_note/submit', | ||
async (args: { id: string; value: string }, { getState }) => { | ||
// TODO: replace `unknown` with `ApiRelationshipJSON` when it is merged | ||
const response = await api(getState).post<unknown>( | ||
`/api/v1/accounts/${args.id}/note`, | ||
{ | ||
comment: args.value, | ||
}, | ||
); | ||
|
||
return { relationship: response.data }; | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { AxiosResponse, RawAxiosRequestHeaders } from 'axios'; | ||
import axios from 'axios'; | ||
import LinkHeader from 'http-link-header'; | ||
|
||
import ready from './ready'; | ||
import type { GetState } from './store'; | ||
|
||
export const getLinks = (response: AxiosResponse) => { | ||
const value = response.headers.link as string | undefined; | ||
|
||
if (!value) { | ||
return new LinkHeader(); | ||
} | ||
|
||
return LinkHeader.parse(value); | ||
}; | ||
|
||
const csrfHeader: RawAxiosRequestHeaders = {}; | ||
|
||
const setCSRFHeader = () => { | ||
const csrfToken = document.querySelector<HTMLMetaElement>( | ||
'meta[name=csrf-token]', | ||
); | ||
|
||
if (csrfToken) { | ||
csrfHeader['X-CSRF-Token'] = csrfToken.content; | ||
} | ||
}; | ||
|
||
void ready(setCSRFHeader); | ||
|
||
const authorizationHeaderFromState = (getState?: GetState) => { | ||
const accessToken = | ||
getState && (getState().meta.get('access_token', '') as string); | ||
|
||
if (!accessToken) { | ||
return {}; | ||
} | ||
|
||
return { | ||
Authorization: `Bearer ${accessToken}`, | ||
} as RawAxiosRequestHeaders; | ||
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function api(getState: GetState) { | ||
return axios.create({ | ||
headers: { | ||
...csrfHeader, | ||
...authorizationHeaderFromState(getState), | ||
}, | ||
|
||
transformResponse: [ | ||
function (data: unknown) { | ||
try { | ||
return JSON.parse(data as string) as unknown; | ||
} catch { | ||
return data; | ||
} | ||
}, | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.