Added is_renote
ci/woodpecker/push/ociImagePush Pipeline is running
Details
ci/woodpecker/push/ociImagePush Pipeline is running
Details
This commit is contained in:
parent
024cdef68c
commit
c6d84d6287
|
@ -61,6 +61,7 @@ pub struct Model {
|
|||
#[sea_orm(column_name = "updatedAt")]
|
||||
pub updated_at: Option<DateTimeWithTimeZone>,
|
||||
pub is_quote: Option<bool>,
|
||||
pub is_renote: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -6,6 +6,7 @@ mod m20230729_212237_user_unique_idx;
|
|||
mod m20230806_142918_drop_featured_note_option;
|
||||
mod m20240107_005747_remove_user_groups;
|
||||
mod m20240107_220523_generated_is_quote;
|
||||
mod m20240107_224446_generated_is_renote;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
@ -19,6 +20,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20230806_142918_drop_featured_note_option::Migration),
|
||||
Box::new(m20240107_005747_remove_user_groups::Migration),
|
||||
Box::new(m20240107_220523_generated_is_quote::Migration),
|
||||
Box::new(m20240107_224446_generated_is_renote::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ impl MigrationTrait for Migration {
|
|||
|
||||
db.execute_unprepared(
|
||||
r#"
|
||||
ALTER TABLE "note" ADD COLUMN "is_quote" BOOLEAN GENERATED ALWAYS AS (
|
||||
ALTER TABLE "note" ADD COLUMN "is_quote" BOOLEAN GENERATED ALWAYS AS (
|
||||
"note"."renoteId" IS NOT NULL
|
||||
AND
|
||||
(
|
||||
|
@ -18,6 +18,8 @@ impl MigrationTrait for Migration {
|
|||
OR
|
||||
CARDINALITY(note."fileIds") != 0
|
||||
OR
|
||||
"note"."cw" IS NOT NULL AND note."cw" != ''
|
||||
OR
|
||||
note."hasPoll" = TRUE
|
||||
)
|
||||
) STORED
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let db = manager.get_connection();
|
||||
|
||||
db.execute_unprepared(
|
||||
r#"
|
||||
ALTER TABLE "note" ADD COLUMN "is_renote" BOOLEAN GENERATED ALWAYS AS (
|
||||
"note"."renoteId" IS NOT NULL
|
||||
AND
|
||||
(
|
||||
(note.text IS NULL OR note.text = '')
|
||||
AND
|
||||
CARDINALITY(note."fileIds") = 0
|
||||
AND
|
||||
("note"."cw" IS NULL OR note."cw" = '')
|
||||
AND
|
||||
note."hasPoll" = FALSE
|
||||
)
|
||||
) STORED
|
||||
"#,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let db = manager.get_connection();
|
||||
|
||||
db.execute_unprepared(
|
||||
r#"
|
||||
ALTER TABLE "note" DROP COLUMN "is_renote";
|
||||
"#,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
v-size="{ max: [500, 350] }"
|
||||
class="tkcbzcuz note-container"
|
||||
:tabindex="!isDeleted ? '-1' : null"
|
||||
:class="{ renote: isRenote }"
|
||||
:class="{ renote: note.is_renote }"
|
||||
:id="appearNote.id"
|
||||
>
|
||||
<XNoteSub
|
||||
|
@ -33,7 +33,7 @@
|
|||
<i class="ph-push-pin ph-bold ph-lg"></i
|
||||
>{{ i18n.ts.pinnedNote }}
|
||||
</div>
|
||||
<div v-if="isRenote" class="renote">
|
||||
<div v-if="note.is_renote" class="renote">
|
||||
<i class="ph-repeat ph-bold ph-lg"></i>
|
||||
<I18n :src="i18n.ts.renotedBy" tag="span">
|
||||
<template #user>
|
||||
|
@ -250,7 +250,6 @@ import { packed } from "magnetar-common";
|
|||
import {
|
||||
magEffectiveNote,
|
||||
magHasReacted,
|
||||
magIsRenote,
|
||||
magReactionCount,
|
||||
magReactionSelf,
|
||||
magReactionToLegacy,
|
||||
|
@ -288,8 +287,6 @@ if (noteViewInterruptors.length > 0) {
|
|||
});
|
||||
}
|
||||
|
||||
const isRenote = magIsRenote(note);
|
||||
|
||||
const el = ref<HTMLElement | null>(null);
|
||||
const footerEl = ref<HTMLElement | null>(null);
|
||||
const menuButton = ref<HTMLElement | null>(null);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
v-size="{ max: [500, 350, 300] }"
|
||||
class="lxwezrsl _block"
|
||||
:tabindex="!isDeleted ? '-1' : null"
|
||||
:class="{ renote: magIsRenote(note) }"
|
||||
:class="{ renote: note.is_renote }"
|
||||
>
|
||||
<MagNoteSub
|
||||
v-if="conversation"
|
||||
|
@ -175,7 +175,6 @@ import { NoteUpdatedEvent } from "calckey-js/built/streaming.types";
|
|||
import { endpoints, packed } from "magnetar-common";
|
||||
import {
|
||||
magEffectiveNote,
|
||||
magIsRenote,
|
||||
magReactionCount,
|
||||
magReactionToLegacy,
|
||||
resolveNote,
|
||||
|
|
|
@ -78,7 +78,7 @@ import * as os from "@/os";
|
|||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { i18n } from "@/i18n";
|
||||
import { endpoints, packed } from "magnetar-common";
|
||||
import { magIsRenote, magTransUsername } from "@/scripts-mag/mag-util";
|
||||
import { magEffectiveNote, magTransUsername } from "@/scripts-mag/mag-util";
|
||||
|
||||
const props = defineProps<{
|
||||
noteId: string;
|
||||
|
@ -90,7 +90,6 @@ let hasNext = $ref(false);
|
|||
let showPrev = $ref(false);
|
||||
let showNext = $ref(false);
|
||||
let error = $ref();
|
||||
let isRenote = $ref(false);
|
||||
let appearNote = $ref<null | packed.PackNoteMaybeFull>();
|
||||
|
||||
const prevPagination = {
|
||||
|
@ -134,10 +133,7 @@ function fetchNote() {
|
|||
)
|
||||
.then((res) => {
|
||||
note = res;
|
||||
isRenote = magIsRenote(note);
|
||||
appearNote = isRenote
|
||||
? (note.renoted_note as packed.PackNoteMaybeFull)
|
||||
: note;
|
||||
appearNote = magEffectiveNote(note);
|
||||
|
||||
Promise.all([
|
||||
os.api("users/notes", {
|
||||
|
|
|
@ -143,25 +143,10 @@ export function noteIsMag(
|
|||
return "created_at" in note;
|
||||
}
|
||||
|
||||
export function magIsRenote(
|
||||
note: packed.PackNoteMaybeFull | Misskey.entities.Note
|
||||
): boolean {
|
||||
return (
|
||||
(magTransProperty(note, "renoted_note", "renote") || null) !== null &&
|
||||
(note.text || null) === null &&
|
||||
magTransProperty(note, "file_ids", "fileIds").length === 0 &&
|
||||
(note.poll || null) === null
|
||||
);
|
||||
}
|
||||
|
||||
export function magEffectiveNote(
|
||||
note: packed.PackNoteMaybeFull | Misskey.entities.Note
|
||||
): packed.PackNoteMaybeFull | Misskey.entities.Note {
|
||||
return magIsRenote(note)
|
||||
? (magTransProperty(note, "renoted_note", "renote") as
|
||||
| packed.PackNoteMaybeFull
|
||||
| Misskey.entities.Note)
|
||||
: note;
|
||||
note: packed.PackNoteMaybeFull
|
||||
): packed.PackNoteMaybeFull {
|
||||
return note.is_renote && note.renoted_note ? note.renoted_note : note;
|
||||
}
|
||||
|
||||
export function magLegacyVisibility(
|
||||
|
|
|
@ -5,4 +5,4 @@ import type { NoteVisibility } from "./NoteVisibility";
|
|||
import type { PackUserBase } from "./packed/PackUserBase";
|
||||
import type { ReactionPair } from "./ReactionPair";
|
||||
|
||||
export interface NoteBase { created_at: string, updated_at: string | null, cw: string | null, cw_mm: MmXml | null, uri: string | null, url: string | null, text: string, text_mm: MmXml | null, visibility: NoteVisibility, user: PackUserBase, parent_note_id: string | null, renoted_note_id: string | null, reply_count: number, renote_count: number, mentions: Array<string>, visible_user_ids: Array<string> | null, hashtags: Array<string>, reactions: Array<ReactionPair>, local_only: boolean, has_poll: boolean, file_ids: Array<string>, emojis: EmojiContext, is_quote: boolean, }
|
||||
export interface NoteBase { created_at: string, updated_at: string | null, cw: string | null, cw_mm: MmXml | null, uri: string | null, url: string | null, text: string, text_mm: MmXml | null, visibility: NoteVisibility, user: PackUserBase, parent_note_id: string | null, renoted_note_id: string | null, reply_count: number, renote_count: number, mentions: Array<string>, visible_user_ids: Array<string> | null, hashtags: Array<string>, reactions: Array<ReactionPair>, local_only: boolean, has_poll: boolean, file_ids: Array<string>, emojis: EmojiContext, is_quote: boolean, is_renote: boolean, }
|
|
@ -73,6 +73,7 @@ pub struct NoteBase {
|
|||
pub file_ids: Vec<String>,
|
||||
pub emojis: EmojiContext,
|
||||
pub is_quote: bool,
|
||||
pub is_renote: bool,
|
||||
}
|
||||
|
||||
pack!(PackNoteBase, Required<Id> as id & Required<NoteBase> as note);
|
||||
|
|
|
@ -72,6 +72,7 @@ impl PackType<NoteBaseSource<'_>> for NoteBase {
|
|||
file_ids: note.file_ids.clone(),
|
||||
emojis: emoji_context.clone(),
|
||||
is_quote: note.is_quote.unwrap_or_default(),
|
||||
is_renote: note.is_renote.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue