Add oauth token to websocket connection
This commit is contained in:
parent
d3b599738e
commit
aab4433a55
@ -2,6 +2,7 @@ HASHTAG_FILTER = ichlausche,music,musik,nowplaying,tunetuesday,nowlistening
|
|||||||
YOUTUBE_API_KEY = CHANGE_ME
|
YOUTUBE_API_KEY = CHANGE_ME
|
||||||
ODESLI_API_KEY = CHANGE_ME
|
ODESLI_API_KEY = CHANGE_ME
|
||||||
MASTODON_INSTANCE = 'metalhead.club'
|
MASTODON_INSTANCE = 'metalhead.club'
|
||||||
|
MASTODON_ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN_HERE'
|
||||||
BASE_URL = 'https://moshingmammut.phlaym.net'
|
BASE_URL = 'https://moshingmammut.phlaym.net'
|
||||||
VERBOSE = false
|
VERBOSE = false
|
||||||
IGNORE_USERS = @moshhead@metalhead.club
|
IGNORE_USERS = @moshhead@metalhead.club
|
||||||
|
@ -103,6 +103,13 @@ because the API is the only way to check if a YouTube link leads to music or som
|
|||||||
|
|
||||||
If `ODESLI_API_KEY` is unset, your rate limit to the song.link API will be lower.
|
If `ODESLI_API_KEY` is unset, your rate limit to the song.link API will be lower.
|
||||||
|
|
||||||
|
Add `MASTODON_ACCESS_TOKEN` as well, see [Creating our application
|
||||||
|
|
||||||
|
](https://docs.joinmastodon.org/client/token/#app) in the Mastodon documentation.
|
||||||
|
`read:statuses` is the only required scope. An access token will be displayed in your settings. Use that!
|
||||||
|
|
||||||
|
There are currently no plans to implement an actual authentication flow.
|
||||||
|
|
||||||
Run `npm run build` and copy the output folder, usually `build` to `$APP_DIR` on your server.
|
Run `npm run build` and copy the output folder, usually `build` to `$APP_DIR` on your server.
|
||||||
|
|
||||||
#### On your server again
|
#### On your server again
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
HASHTAG_FILTER,
|
HASHTAG_FILTER,
|
||||||
|
MASTODON_ACCESS_TOKEN,
|
||||||
MASTODON_INSTANCE,
|
MASTODON_INSTANCE,
|
||||||
ODESLI_API_KEY,
|
ODESLI_API_KEY,
|
||||||
YOUTUBE_API_KEY
|
YOUTUBE_API_KEY
|
||||||
@ -352,10 +353,11 @@ export class TimelineReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private startWebsocket() {
|
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 = () => {
|
socket.onopen = () => {
|
||||||
log.log('Connected to WS');
|
log.log('Connected to WS');
|
||||||
socket.send('{ "type": "subscribe", "stream": "public:local"}');
|
|
||||||
};
|
};
|
||||||
socket.onmessage = async (event) => {
|
socket.onmessage = async (event) => {
|
||||||
try {
|
try {
|
||||||
@ -392,7 +394,8 @@ export class TimelineReader {
|
|||||||
};
|
};
|
||||||
socket.onclose = (event) => {
|
socket.onclose = (event) => {
|
||||||
log.warn(
|
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(() => {
|
setTimeout(() => {
|
||||||
log.info(`Attempting to reconenct to WS`);
|
log.info(`Attempting to reconenct to WS`);
|
||||||
|
Loading…
Reference in New Issue
Block a user