Add oauth token to websocket connection
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import {
|
||||
HASHTAG_FILTER,
|
||||
MASTODON_ACCESS_TOKEN,
|
||||
MASTODON_INSTANCE,
|
||||
ODESLI_API_KEY,
|
||||
YOUTUBE_API_KEY
|
||||
@ -352,10 +353,11 @@ export class TimelineReader {
|
||||
}
|
||||
|
||||
private startWebsocket() {
|
||||
const socket = new WebSocket(`wss://${MASTODON_INSTANCE}/api/v1/streaming`);
|
||||
const socket = new WebSocket(
|
||||
`wss://${MASTODON_INSTANCE}/api/v1/streaming?type=subscribe&stream=public:local&access_token=${MASTODON_ACCESS_TOKEN}`
|
||||
);
|
||||
socket.onopen = () => {
|
||||
log.log('Connected to WS');
|
||||
socket.send('{ "type": "subscribe", "stream": "public:local"}');
|
||||
};
|
||||
socket.onmessage = async (event) => {
|
||||
try {
|
||||
@ -392,7 +394,8 @@ export class TimelineReader {
|
||||
};
|
||||
socket.onclose = (event) => {
|
||||
log.warn(
|
||||
`Websocket connection to ${MASTODON_INSTANCE} closed. Code: ${event.code}, reason: '${event.reason}'`
|
||||
`Websocket connection to ${MASTODON_INSTANCE} closed. Code: ${event.code}, reason: '${event.reason}'`,
|
||||
event
|
||||
);
|
||||
setTimeout(() => {
|
||||
log.info(`Attempting to reconenct to WS`);
|
||||
|
Reference in New Issue
Block a user