[mastodon-client] Add support for public:allow_local_only stream

This commit is contained in:
Laura Hausmann 2023-10-13 23:04:52 +02:00
parent f14b3cec97
commit b5393e41d0
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 5 additions and 0 deletions

View file

@ -13,12 +13,14 @@ export class MastodonStreamPublic extends MastodonStream {
private readonly mediaOnly: boolean;
private readonly localOnly: boolean;
private readonly remoteOnly: boolean;
private readonly allowLocalOnly: boolean;
constructor(connection: MastodonStream["connection"], name: string) {
super(connection, name);
this.mediaOnly = name.endsWith(":media");
this.localOnly = name.startsWith("public:local");
this.remoteOnly = name.startsWith("public:remote");
this.allowLocalOnly = name.startsWith("public:allow_local_only");
this.onNote = this.onNote.bind(this);
this.onNoteEvent = this.onNoteEvent.bind(this);
}
@ -64,6 +66,7 @@ export class MastodonStreamPublic extends MastodonStream {
if (this.mediaOnly && note.fileIds.length < 1) return false;
if (this.localOnly && note.userHost !== null) return false;
if (this.remoteOnly && note.userHost === null) return false;
if (note.localOnly && !this.allowLocalOnly && !this.localOnly) return false;
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return false;
if (isUserRelated(note, this.muting)) return false;
if (isUserRelated(note, this.blocking)) return false;

View file

@ -28,6 +28,8 @@ const channels: Record<string, any> = {
"public:local:media": MastodonStreamPublic,
"public:remote": MastodonStreamPublic,
"public:remote:media": MastodonStreamPublic,
"public:allow_local_only": MastodonStreamPublic,
"public:allow_local_only:media": MastodonStreamPublic,
"hashtag": MastodonStreamTag,
"hashtag:local": MastodonStreamTag,
}