prepare for being available on multiple domain names
This commit is contained in:
@ -2,6 +2,7 @@ import {
|
||||
HASHTAG_FILTER,
|
||||
MASTODON_ACCESS_TOKEN,
|
||||
MASTODON_INSTANCE,
|
||||
IGNORE_USERS,
|
||||
ODESLI_API_KEY,
|
||||
YOUTUBE_API_KEY
|
||||
} from '$env/static/private';
|
||||
@ -48,6 +49,7 @@ export class TimelineReader {
|
||||
private lastPosts: string[] = [];
|
||||
private playlistAdders: PlaylistAdder[];
|
||||
private logger: Logger;
|
||||
private ignoredUsers: string[];
|
||||
|
||||
private async isMusicVideo(videoId: string) {
|
||||
if (!YOUTUBE_API_KEY || YOUTUBE_API_KEY === 'CHANGE_ME') {
|
||||
@ -372,6 +374,20 @@ export class TimelineReader {
|
||||
}
|
||||
|
||||
private async checkAndSavePost(post: Post) {
|
||||
if (IGNORE_USERS !== undefined && IGNORE_USERS !== '' && IGNORE_USERS !== 'CHANGE_ME') {
|
||||
const ignorelist = IGNORE_USERS.split(',');
|
||||
const isIgnored = ignorelist.includes(post.account.username);
|
||||
const isIgnoredDb = this.ignoredUsers.includes(post.account.username);
|
||||
this.logger.debug(
|
||||
'Check if user',
|
||||
post.account.username,
|
||||
'is ignored',
|
||||
this.ignoredUsers,
|
||||
isIgnored,
|
||||
isIgnoredDb
|
||||
);
|
||||
}
|
||||
|
||||
const hashttags: string[] = HASHTAG_FILTER.split(',');
|
||||
const found_tags: Tag[] = post.tags.filter((t: Tag) => hashttags.includes(t.name));
|
||||
|
||||
@ -480,6 +496,16 @@ export class TimelineReader {
|
||||
this.logger = new Logger('Timeline');
|
||||
this.logger.log('Constructing timeline object');
|
||||
this.playlistAdders = [new YoutubePlaylistAdder(), new SpotifyPlaylistAdder()];
|
||||
this.ignoredUsers =
|
||||
IGNORE_USERS === undefined
|
||||
? []
|
||||
: IGNORE_USERS.split(',')
|
||||
.map((u) => (u.startsWith('@') ? u.substring(1) : u))
|
||||
.map((u) =>
|
||||
u.endsWith('@' + MASTODON_INSTANCE)
|
||||
? u.substring(0, u.length - ('@' + MASTODON_INSTANCE).length)
|
||||
: u
|
||||
);
|
||||
this.startWebsocket();
|
||||
|
||||
this.loadPostsSinceLastRun()
|
||||
|
Reference in New Issue
Block a user