mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[mastodon-client] Switch to isQuote for detecting quotes
This commit is contained in:
parent
44fb31ab13
commit
b48594ef68
@ -20,6 +20,7 @@ import { IsNull } from "typeorm";
|
||||
import { MfmHelpers } from "@/server/api/mastodon/helpers/mfm.js";
|
||||
import { getStubMastoContext, MastoContext } from "@/server/api/mastodon/index.js";
|
||||
import { NoteHelpers } from "@/server/api/mastodon/helpers/note.js";
|
||||
import isQuote from "@/misc/is-quote.js";
|
||||
|
||||
export class NoteConverter {
|
||||
public static async encode(note: Note, ctx: MastoContext, recurse: boolean = true): Promise<MastodonEntity.Status> {
|
||||
@ -88,7 +89,7 @@ export class NoteConverter {
|
||||
.then(p => p.filter(m => m)) as Promise<MastodonEntity.Mention[]>;
|
||||
|
||||
const quoteUri = Promise.resolve(renote).then(renote => {
|
||||
if (!renote || note.text === null) return null;
|
||||
if (!renote || !isQuote(note)) return null;
|
||||
return renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`;
|
||||
});
|
||||
|
||||
@ -118,7 +119,7 @@ export class NoteConverter {
|
||||
account: Promise.resolve(noteUser).then(p => UserConverter.encode(p, ctx)),
|
||||
in_reply_to_id: note.replyId,
|
||||
in_reply_to_account_id: note.replyUserId,
|
||||
reblog: reblog.then(reblog => note.text === null ? reblog : null),
|
||||
reblog: reblog.then(reblog => !isQuote(note) ? reblog : null),
|
||||
content: content,
|
||||
content_type: 'text/x.misskeymarkdown',
|
||||
text: note.text,
|
||||
@ -143,7 +144,7 @@ export class NoteConverter {
|
||||
pinned: isPinned,
|
||||
reactions: populated.then(populated => Promise.resolve(reaction).then(reaction => this.encodeReactions(note.reactions, reaction?.reaction, populated))),
|
||||
bookmarked: isBookmarked,
|
||||
quote: reblog.then(reblog => note.text !== null ? reblog : null),
|
||||
quote: reblog.then(reblog => isQuote(note) ? reblog : null),
|
||||
edited_at: note.updatedAt?.toISOString()
|
||||
});
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
|
||||
import { getNote } from "@/server/api/common/getters.js";
|
||||
import { getStubMastoContext, MastoContext } from "@/server/api/mastodon/index.js";
|
||||
import { Notifications } from "@/models/index.js";
|
||||
import isQuote from "@/misc/is-quote.js";
|
||||
|
||||
type NotificationType = typeof notificationTypes[number];
|
||||
|
||||
@ -30,7 +31,7 @@ export class NotificationConverter {
|
||||
const note = notification.note ?? (notification.noteId ? await getNote(notification.noteId, localUser) : null);
|
||||
|
||||
if (note) {
|
||||
const isPureRenote = note.renoteId !== null && note.text === null;
|
||||
const isPureRenote = note.renoteId !== null && !isQuote(note);
|
||||
const encodedNote = isPureRenote
|
||||
? getNote(note.renoteId!, localUser).then(note => NoteConverter.encode(note, ctx))
|
||||
: NoteConverter.encode(note, ctx);
|
||||
|
@ -236,6 +236,8 @@ export class NoteHelpers {
|
||||
)
|
||||
.andWhere("note.renoteId = :noteId", { noteId: note.id })
|
||||
.andWhere("note.text IS NULL") // We don't want to count quotes as renotes
|
||||
.andWhere('note.hasPoll = FALSE')
|
||||
.andWhere("note.fileIds = '{}'")
|
||||
.innerJoinAndSelect("note.user", "user");
|
||||
|
||||
generateVisibilityQuery(query, user);
|
||||
|
@ -353,7 +353,9 @@ export class UserHelpers {
|
||||
query.andWhere(
|
||||
new Brackets(qb => {
|
||||
qb.where('note.renoteId IS NULL')
|
||||
.orWhere('note.text IS NOT NULL');
|
||||
.orWhere('note.text IS NOT NULL')
|
||||
.orWhere('note.hasPoll = TRUE')
|
||||
.orWhere("note.fileIds != '{}'");
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import { Note } from "@/models/entities/note.js";
|
||||
import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
|
||||
import { StreamMessages } from "@/server/api/stream/types.js";
|
||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||
import isQuote from "@/misc/is-quote.js";
|
||||
|
||||
export class MastodonStreamPublic extends MastodonStream {
|
||||
public static shouldShare = true;
|
||||
@ -70,7 +71,7 @@ export class MastodonStreamPublic extends MastodonStream {
|
||||
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;
|
||||
if (note.renote && !note.text && this.renoteMuting.has(note.userId)) return false;
|
||||
if (note.renote && !isQuote(note) && this.renoteMuting.has(note.userId)) return false;
|
||||
if (this.userProfile && (await getWordHardMute(note, this.user, this.userProfile.mutedWords))) return false;
|
||||
|
||||
return true;
|
||||
|
@ -5,6 +5,7 @@ import { isInstanceMuted } from "@/misc/is-instance-muted.js";
|
||||
import { Note } from "@/models/entities/note.js";
|
||||
import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
|
||||
import { StreamMessages } from "@/server/api/stream/types.js";
|
||||
import isQuote from "@/misc/is-quote.js";
|
||||
|
||||
export class MastodonStreamTag extends MastodonStream {
|
||||
public static shouldShare = false;
|
||||
@ -62,7 +63,7 @@ export class MastodonStreamTag extends MastodonStream {
|
||||
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;
|
||||
if (note.renote && !note.text && this.renoteMuting.has(note.userId)) return false;
|
||||
if (note.renote && !isQuote(note) && this.renoteMuting.has(note.userId)) return false;
|
||||
if (this.userProfile && (await getWordHardMute(note, this.user, this.userProfile.mutedWords))) return false;
|
||||
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@ import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
|
||||
import { StreamMessages } from "@/server/api/stream/types.js";
|
||||
import { NotificationConverter } from "@/server/api/mastodon/converters/notification.js";
|
||||
import { AnnouncementConverter } from "@/server/api/mastodon/converters/announcement.js";
|
||||
import isQuote from "@/misc/is-quote.js";
|
||||
|
||||
export class MastodonStreamUser extends MastodonStream {
|
||||
public static shouldShare = true;
|
||||
@ -95,7 +96,7 @@ export class MastodonStreamUser extends MastodonStream {
|
||||
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;
|
||||
if (note.renote && !note.text && this.renoteMuting.has(note.userId)) return false;
|
||||
if (note.renote && !isQuote(note) && this.renoteMuting.has(note.userId)) return false;
|
||||
if (this.userProfile && (await getWordHardMute(note, this.user, this.userProfile.mutedWords))) return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user