mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 11:27:31 -07:00
[mastodon-client] Add support for public:allow_local_only stream
This commit is contained in:
parent
f14b3cec97
commit
b5393e41d0
2 changed files with 5 additions and 0 deletions
|
@ -13,12 +13,14 @@ export class MastodonStreamPublic extends MastodonStream {
|
||||||
private readonly mediaOnly: boolean;
|
private readonly mediaOnly: boolean;
|
||||||
private readonly localOnly: boolean;
|
private readonly localOnly: boolean;
|
||||||
private readonly remoteOnly: boolean;
|
private readonly remoteOnly: boolean;
|
||||||
|
private readonly allowLocalOnly: boolean;
|
||||||
|
|
||||||
constructor(connection: MastodonStream["connection"], name: string) {
|
constructor(connection: MastodonStream["connection"], name: string) {
|
||||||
super(connection, name);
|
super(connection, name);
|
||||||
this.mediaOnly = name.endsWith(":media");
|
this.mediaOnly = name.endsWith(":media");
|
||||||
this.localOnly = name.startsWith("public:local");
|
this.localOnly = name.startsWith("public:local");
|
||||||
this.remoteOnly = name.startsWith("public:remote");
|
this.remoteOnly = name.startsWith("public:remote");
|
||||||
|
this.allowLocalOnly = name.startsWith("public:allow_local_only");
|
||||||
this.onNote = this.onNote.bind(this);
|
this.onNote = this.onNote.bind(this);
|
||||||
this.onNoteEvent = this.onNoteEvent.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.mediaOnly && note.fileIds.length < 1) return false;
|
||||||
if (this.localOnly && note.userHost !== null) return false;
|
if (this.localOnly && note.userHost !== null) return false;
|
||||||
if (this.remoteOnly && 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 (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return false;
|
||||||
if (isUserRelated(note, this.muting)) return false;
|
if (isUserRelated(note, this.muting)) return false;
|
||||||
if (isUserRelated(note, this.blocking)) return false;
|
if (isUserRelated(note, this.blocking)) return false;
|
||||||
|
|
|
@ -28,6 +28,8 @@ const channels: Record<string, any> = {
|
||||||
"public:local:media": MastodonStreamPublic,
|
"public:local:media": MastodonStreamPublic,
|
||||||
"public:remote": MastodonStreamPublic,
|
"public:remote": MastodonStreamPublic,
|
||||||
"public:remote:media": MastodonStreamPublic,
|
"public:remote:media": MastodonStreamPublic,
|
||||||
|
"public:allow_local_only": MastodonStreamPublic,
|
||||||
|
"public:allow_local_only:media": MastodonStreamPublic,
|
||||||
"hashtag": MastodonStreamTag,
|
"hashtag": MastodonStreamTag,
|
||||||
"hashtag:local": MastodonStreamTag,
|
"hashtag:local": MastodonStreamTag,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue