feat: メディアタイムラインを輸入 (#103)

* メディアタイムラインの実装

* refactor(stream): ストリーミングにwithFilesオプションを実装

---------

Co-authored-by: tar_bin <tar.bin.master@gmail.com>
This commit is contained in:
まっちゃとーにゅ 2023-07-24 02:48:01 +09:00 committed by mattyatea
parent bbd5282dc6
commit 1516de1fee
13 changed files with 50 additions and 22 deletions

View file

@ -19,6 +19,7 @@ class GlobalTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = false;
private withReplies: boolean;
private withFiles: boolean;
constructor(
private metaService: MetaService,
@ -38,6 +39,7 @@ class GlobalTimelineChannel extends Channel {
if (!policies.gtlAvailable) return;
this.withReplies = params.withReplies as boolean;
this.withFiles = params.withFiles as boolean;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@ -48,6 +50,9 @@ class GlobalTimelineChannel extends Channel {
if (note.visibility !== 'public') return;
if (note.channelId != null) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
// リプライなら再pack
if (note.replyId != null) {
note.reply = await this.noteEntityService.pack(note.replyId, this.user, {

View file

@ -17,6 +17,7 @@ class HomeTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = true;
private withReplies: boolean;
private withFiles: boolean;
constructor(
private noteEntityService: NoteEntityService,
@ -31,6 +32,7 @@ class HomeTimelineChannel extends Channel {
@bindThis
public async init(params: any) {
this.withReplies = params.withReplies as boolean;
this.withFiles = params.withFiles as boolean;
this.subscriber.on('notesStream', this.onNote);
}
@ -47,6 +49,9 @@ class HomeTimelineChannel extends Channel {
// Ignore notes from instances the user has muted
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances ?? []))) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
if (['followers', 'specified'].includes(note.visibility)) {
note = await this.noteEntityService.pack(note.id, this.user!, {
detail: true,

View file

@ -19,6 +19,7 @@ class HybridTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = true;
private withReplies: boolean;
private withFiles: boolean;
constructor(
private metaService: MetaService,
@ -38,6 +39,7 @@ class HybridTimelineChannel extends Channel {
if (!policies.ltlAvailable) return;
this.withReplies = params.withReplies as boolean;
this.withFiles = params.withFiles as boolean;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@ -56,6 +58,9 @@ class HybridTimelineChannel extends Channel {
(note.channelId != null && this.followingChannels.has(note.channelId))
)) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
if (['followers', 'specified'].includes(note.visibility)) {
note = await this.noteEntityService.pack(note.id, this.user!, {
detail: true,

View file

@ -18,6 +18,7 @@ class LocalTimelineChannel extends Channel {
public static shouldShare = true;
public static requireCredential = false;
private withReplies: boolean;
private withFiles: boolean;
constructor(
private metaService: MetaService,
@ -37,6 +38,7 @@ class LocalTimelineChannel extends Channel {
if (!policies.ltlAvailable) return;
this.withReplies = params.withReplies as boolean;
this.withFiles = params.withFiles as boolean;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@ -48,6 +50,9 @@ class LocalTimelineChannel extends Channel {
if (note.visibility !== 'public') return;
if (note.channelId != null && !this.followingChannels.has(note.channelId)) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
// リプライなら再pack
if (note.replyId != null) {
note.reply = await this.noteEntityService.pack(note.replyId, this.user, {