mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-31 17:45:22 +01:00
Merge pull request #1033 from h3poteto/iss-1028
closes #1028 Use authorized request to get instance information when start streamings
This commit is contained in:
commit
501c79c621
@ -1,9 +1,13 @@
|
||||
import Mastodon, { WebSocket as SocketListener, Status, Notification, Instance } from 'megalodon'
|
||||
import Mastodon, { WebSocket as SocketListener, Status, Notification, Instance, Response } from 'megalodon'
|
||||
import log from 'electron-log'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
const StreamingURL = async (account: LocalAccount): Promise<string> => {
|
||||
const res = await Mastodon.get<Instance>('/api/v1/instance', {}, account.baseURL)
|
||||
if (!account.accessToken) {
|
||||
throw new Error('access token is empty')
|
||||
}
|
||||
const client = new Mastodon(account.accessToken, account.baseURL + '/api/v1')
|
||||
const res: Response<Instance> = await client.get<Instance>('/instance')
|
||||
return res.data.urls.streaming_api
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user