From 0510b0920e146cefc135d54b8f39d9b7a3955d8a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 14 Sep 2019 22:44:43 +0900
Subject: [PATCH] refs #1028 Use authorized request to get instance information
when start streamings
---
src/main/websocket.ts | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main/websocket.ts b/src/main/websocket.ts
index 2b5e5f4c..42f035d3 100644
--- a/src/main/websocket.ts
+++ b/src/main/websocket.ts
@@ -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 => {
- const res = await Mastodon.get('/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 = await client.get('/instance')
return res.data.urls.streaming_api
}