add lang field
This commit is contained in:
parent
f0d3f71656
commit
c050ee03fc
10 changed files with 61 additions and 43 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE note DROP "lang";
|
||||||
|
ALTER TABLE home_timeline DROP "lang";
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE note ADD "lang" ascii;
|
||||||
|
ALTER TABLE home_timeline ADD "lang" ascii;
|
|
@ -16,6 +16,7 @@ pub struct Model {
|
||||||
pub renote_id: Option<String>,
|
pub renote_id: Option<String>,
|
||||||
#[sea_orm(column_type = "Text", nullable)]
|
#[sea_orm(column_type = "Text", nullable)]
|
||||||
pub text: Option<String>,
|
pub text: Option<String>,
|
||||||
|
pub lang: Option<String>,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub cw: Option<String>,
|
pub cw: Option<String>,
|
||||||
#[sea_orm(column_name = "userId")]
|
#[sea_orm(column_name = "userId")]
|
||||||
|
|
|
@ -369,6 +369,7 @@ impl Initializer {
|
||||||
id: note.id.clone(),
|
id: note.id.clone(),
|
||||||
visibility: note.visibility.to_value(),
|
visibility: note.visibility.to_value(),
|
||||||
content: note.text,
|
content: note.text,
|
||||||
|
lang: note.lang,
|
||||||
name: note.name,
|
name: note.name,
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
local_only: note.local_only,
|
local_only: note.local_only,
|
||||||
|
@ -419,6 +420,7 @@ impl Initializer {
|
||||||
id: s_note.id,
|
id: s_note.id,
|
||||||
visibility: s_note.visibility,
|
visibility: s_note.visibility,
|
||||||
content: s_note.content,
|
content: s_note.content,
|
||||||
|
lang: s_note.lang,
|
||||||
name: s_note.name,
|
name: s_note.name,
|
||||||
cw: s_note.cw,
|
cw: s_note.cw,
|
||||||
local_only: s_note.local_only,
|
local_only: s_note.local_only,
|
||||||
|
@ -658,6 +660,7 @@ struct NoteTable {
|
||||||
id: String,
|
id: String,
|
||||||
visibility: String,
|
visibility: String,
|
||||||
content: Option<String>,
|
content: Option<String>,
|
||||||
|
lang: Option<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
cw: Option<String>,
|
cw: Option<String>,
|
||||||
local_only: bool,
|
local_only: bool,
|
||||||
|
@ -702,6 +705,7 @@ INSERT INTO note (
|
||||||
"id",
|
"id",
|
||||||
"visibility",
|
"visibility",
|
||||||
"content",
|
"content",
|
||||||
|
"lang",
|
||||||
"name",
|
"name",
|
||||||
"cw",
|
"cw",
|
||||||
"localOnly",
|
"localOnly",
|
||||||
|
@ -737,7 +741,7 @@ INSERT INTO note (
|
||||||
"reactions",
|
"reactions",
|
||||||
"noteEdit",
|
"noteEdit",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[derive(Clone, ValueList)]
|
#[derive(Clone, ValueList)]
|
||||||
|
@ -748,6 +752,7 @@ struct HomeTimelineTable {
|
||||||
id: String,
|
id: String,
|
||||||
visibility: String,
|
visibility: String,
|
||||||
content: Option<String>,
|
content: Option<String>,
|
||||||
|
lang: Option<String>,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
cw: Option<String>,
|
cw: Option<String>,
|
||||||
local_only: bool,
|
local_only: bool,
|
||||||
|
@ -793,6 +798,7 @@ INSERT INTO home_timeline (
|
||||||
"id",
|
"id",
|
||||||
"visibility",
|
"visibility",
|
||||||
"content",
|
"content",
|
||||||
|
"lang",
|
||||||
"name",
|
"name",
|
||||||
"cw",
|
"cw",
|
||||||
"localOnly",
|
"localOnly",
|
||||||
|
@ -828,7 +834,7 @@ INSERT INTO home_timeline (
|
||||||
"reactions",
|
"reactions",
|
||||||
"noteEdit",
|
"noteEdit",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[derive(ValueList)]
|
#[derive(ValueList)]
|
||||||
|
|
|
@ -6,6 +6,7 @@ export const scyllaQueries = {
|
||||||
"id",
|
"id",
|
||||||
"visibility",
|
"visibility",
|
||||||
"content",
|
"content",
|
||||||
|
"lang",
|
||||||
"name",
|
"name",
|
||||||
"cw",
|
"cw",
|
||||||
"localOnly",
|
"localOnly",
|
||||||
|
@ -41,7 +42,7 @@ export const scyllaQueries = {
|
||||||
"reactions",
|
"reactions",
|
||||||
"noteEdit",
|
"noteEdit",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
select: {
|
select: {
|
||||||
byDate: `SELECT * FROM note WHERE "createdAtDate" = ?`,
|
byDate: `SELECT * FROM note WHERE "createdAtDate" = ?`,
|
||||||
byUri: `SELECT * FROM note WHERE "uri" = ?`,
|
byUri: `SELECT * FROM note WHERE "uri" = ?`,
|
||||||
|
@ -80,6 +81,7 @@ export const scyllaQueries = {
|
||||||
"id",
|
"id",
|
||||||
"visibility",
|
"visibility",
|
||||||
"content",
|
"content",
|
||||||
|
"lang",
|
||||||
"name",
|
"name",
|
||||||
"cw",
|
"cw",
|
||||||
"localOnly",
|
"localOnly",
|
||||||
|
@ -115,7 +117,7 @@ export const scyllaQueries = {
|
||||||
"reactions",
|
"reactions",
|
||||||
"noteEdit",
|
"noteEdit",
|
||||||
"updatedAt"
|
"updatedAt"
|
||||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
select: {
|
select: {
|
||||||
byUserAndDate: `SELECT * FROM home_timeline WHERE "feedUserId" = ? AND "createdAtDate" = ?`,
|
byUserAndDate: `SELECT * FROM home_timeline WHERE "feedUserId" = ? AND "createdAtDate" = ?`,
|
||||||
byId: `SELECT * FROM home_timeline WHERE "id" = ?`,
|
byId: `SELECT * FROM home_timeline WHERE "id" = ?`,
|
||||||
|
|
|
@ -6,18 +6,9 @@ import { Client, types, tracker } from "cassandra-driver";
|
||||||
import type { User } from "@/models/entities/user.js";
|
import type { User } from "@/models/entities/user.js";
|
||||||
import {
|
import {
|
||||||
Cache,
|
Cache,
|
||||||
ChannelFollowingsCache,
|
|
||||||
InstanceMutingsCache,
|
|
||||||
LocalFollowingsCache,
|
|
||||||
RenoteMutingsCache,
|
|
||||||
UserBlockedCache,
|
|
||||||
UserBlockingCache,
|
|
||||||
UserMutingsCache,
|
|
||||||
userWordMuteCache,
|
|
||||||
} from "@/misc/cache.js";
|
} from "@/misc/cache.js";
|
||||||
import { getTimestamp } from "@/misc/gen-id.js";
|
import { getTimestamp } from "@/misc/gen-id.js";
|
||||||
import Logger from "@/services/logger.js";
|
import Logger from "@/services/logger.js";
|
||||||
import { UserProfiles } from "@/models/index.js";
|
|
||||||
import { getWordHardMute } from "@/misc/check-word-mute.js";
|
import { getWordHardMute } from "@/misc/check-word-mute.js";
|
||||||
import type { UserProfile } from "@/models/entities/user-profile.js";
|
import type { UserProfile } from "@/models/entities/user-profile.js";
|
||||||
import { scyllaQueries } from "@/db/cql.js";
|
import { scyllaQueries } from "@/db/cql.js";
|
||||||
|
@ -134,14 +125,14 @@ export function parseScyllaNotification(row: types.Row): ScyllaNotification {
|
||||||
createdAt: row.get("createdAt"),
|
createdAt: row.get("createdAt"),
|
||||||
id: row.get("id"),
|
id: row.get("id"),
|
||||||
type: row.get("type"),
|
type: row.get("type"),
|
||||||
notifierId: row.get("notifierId") ?? null,
|
notifierId: row.get("notifierId") || null,
|
||||||
notifierHost: row.get("notifierHost") ?? null,
|
notifierHost: row.get("notifierHost") || null,
|
||||||
entityId: row.get("entityId") ?? null,
|
entityId: row.get("entityId") || null,
|
||||||
reaction: row.get("reaction") ?? null,
|
reaction: row.get("reaction") ?? null,
|
||||||
choice: row.get("choice") ?? null,
|
choice: row.get("choice") ?? null,
|
||||||
customBody: row.get("customBody") ?? null,
|
customBody: row.get("customBody") || null,
|
||||||
customHeader: row.get("customHeader") ?? null,
|
customHeader: row.get("customHeader") || null,
|
||||||
customIcon: row.get("customIcon") ?? null,
|
customIcon: row.get("customIcon") || null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +199,7 @@ export function parseScyllaPollVote(row: types.Row): ScyllaPollVote {
|
||||||
return {
|
return {
|
||||||
noteId: row.get("noteId"),
|
noteId: row.get("noteId"),
|
||||||
userId: row.get("userId"),
|
userId: row.get("userId"),
|
||||||
userHost: row.get("userHost") ?? null,
|
userHost: row.get("userHost") || null,
|
||||||
choice: new Set(row.get("choice") ?? []),
|
choice: new Set(row.get("choice") ?? []),
|
||||||
createdAt: row.get("createdAt"),
|
createdAt: row.get("createdAt"),
|
||||||
};
|
};
|
||||||
|
@ -236,14 +227,15 @@ export function parseScyllaNote(row: types.Row): ScyllaNote {
|
||||||
createdAt: row.get("createdAt"),
|
createdAt: row.get("createdAt"),
|
||||||
id: row.get("id"),
|
id: row.get("id"),
|
||||||
visibility: row.get("visibility"),
|
visibility: row.get("visibility"),
|
||||||
text: row.get("content") ?? null,
|
text: row.get("content") || null,
|
||||||
name: row.get("name") ?? null,
|
lang: row.get("lang") || null,
|
||||||
cw: row.get("cw") ?? null,
|
name: row.get("name") || null,
|
||||||
|
cw: row.get("cw") || null,
|
||||||
localOnly: row.get("localOnly"),
|
localOnly: row.get("localOnly"),
|
||||||
renoteCount: row.get("renoteCount"),
|
renoteCount: row.get("renoteCount"),
|
||||||
repliesCount: row.get("repliesCount"),
|
repliesCount: row.get("repliesCount"),
|
||||||
uri: row.get("uri") ?? null,
|
uri: row.get("uri") || null,
|
||||||
url: row.get("url") ?? null,
|
url: row.get("url") || null,
|
||||||
score: row.get("score"),
|
score: row.get("score"),
|
||||||
files,
|
files,
|
||||||
fileIds: files.map((file) => file.id),
|
fileIds: files.map((file) => file.id),
|
||||||
|
@ -254,26 +246,26 @@ export function parseScyllaNote(row: types.Row): ScyllaNote {
|
||||||
tags: row.get("tags") ?? [],
|
tags: row.get("tags") ?? [],
|
||||||
hasPoll: row.get("hasPoll") ?? false,
|
hasPoll: row.get("hasPoll") ?? false,
|
||||||
poll: row.get("poll") ?? null,
|
poll: row.get("poll") ?? null,
|
||||||
threadId: row.get("threadId") ?? null,
|
threadId: row.get("threadId") || null,
|
||||||
channelId: row.get("channelId") ?? null,
|
channelId: row.get("channelId") || null,
|
||||||
userId: row.get("userId"),
|
userId: row.get("userId"),
|
||||||
userHost: userHost !== "local" ? userHost : null,
|
userHost: userHost !== "local" ? userHost : null,
|
||||||
replyId: row.get("replyId") ?? null,
|
replyId: row.get("replyId") || null,
|
||||||
replyUserId: row.get("replyUserId") ?? null,
|
replyUserId: row.get("replyUserId") || null,
|
||||||
replyUserHost: row.get("replyUserHost") ?? null,
|
replyUserHost: row.get("replyUserHost") || null,
|
||||||
replyText: row.get("replyContent") ?? null,
|
replyText: row.get("replyContent") || null,
|
||||||
replyCw: row.get("replyCw") ?? null,
|
replyCw: row.get("replyCw") || null,
|
||||||
replyFiles: row.get("replyFiles") ?? [],
|
replyFiles: row.get("replyFiles") ?? [],
|
||||||
renoteId: row.get("renoteId") ?? null,
|
renoteId: row.get("renoteId") || null,
|
||||||
renoteUserId: row.get("renoteUserId") ?? null,
|
renoteUserId: row.get("renoteUserId") || null,
|
||||||
renoteUserHost: row.get("renoteUserHost") ?? null,
|
renoteUserHost: row.get("renoteUserHost") || null,
|
||||||
renoteText: row.get("renoteContent") ?? null,
|
renoteText: row.get("renoteContent") || null,
|
||||||
renoteCw: row.get("renoteCw") ?? null,
|
renoteCw: row.get("renoteCw") || null,
|
||||||
renoteFiles: row.get("renoteFiles") ?? [],
|
renoteFiles: row.get("renoteFiles") ?? [],
|
||||||
reactions: row.get("reactions") ?? {},
|
reactions: row.get("reactions") ?? {},
|
||||||
noteEdit: row.get("noteEdit") ?? [],
|
noteEdit: row.get("noteEdit") ?? [],
|
||||||
updatedAt: row.get("updatedAt") ?? null,
|
updatedAt: row.get("updatedAt") ?? null,
|
||||||
mentionedRemoteUsers: row.get("mentionedRemoteUsers") ?? "[]",
|
mentionedRemoteUsers: row.get("mentionedRemoteUsers") || "[]",
|
||||||
/* unused postgres denormalization */
|
/* unused postgres denormalization */
|
||||||
channel: null,
|
channel: null,
|
||||||
renote: null,
|
renote: null,
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { extractMentionedUsers } from "@/services/note/create.js";
|
||||||
import { resolvePerson } from "./person.js";
|
import { resolvePerson } from "./person.js";
|
||||||
import { resolveImage } from "./image.js";
|
import { resolveImage } from "./image.js";
|
||||||
import type {
|
import type {
|
||||||
ILocalUser,
|
|
||||||
CacheableRemoteUser,
|
CacheableRemoteUser,
|
||||||
} from "@/models/entities/user.js";
|
} from "@/models/entities/user.js";
|
||||||
import { htmlToMfm } from "../misc/html-to-mfm.js";
|
import { htmlToMfm } from "../misc/html-to-mfm.js";
|
||||||
|
@ -52,7 +51,6 @@ import { In } from "typeorm";
|
||||||
import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js";
|
import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js";
|
||||||
import { truncate } from "@/misc/truncate.js";
|
import { truncate } from "@/misc/truncate.js";
|
||||||
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js";
|
import { type Size, getEmojiSize } from "@/misc/emoji-meta.js";
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
|
||||||
import {
|
import {
|
||||||
type ScyllaNote,
|
type ScyllaNote,
|
||||||
type ScyllaPoll,
|
type ScyllaPoll,
|
||||||
|
@ -878,6 +876,7 @@ export async function updateNote(value: string | IObject, resolver?: Resolver) {
|
||||||
newScyllaNote.id,
|
newScyllaNote.id,
|
||||||
scyllaNote.visibility,
|
scyllaNote.visibility,
|
||||||
newScyllaNote.text,
|
newScyllaNote.text,
|
||||||
|
newScyllaNote.lang,
|
||||||
newScyllaNote.name,
|
newScyllaNote.name,
|
||||||
newScyllaNote.cw,
|
newScyllaNote.cw,
|
||||||
newScyllaNote.localOnly,
|
newScyllaNote.localOnly,
|
||||||
|
|
|
@ -143,7 +143,8 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
.filter((xs) => xs.length > 0);
|
.filter((xs) => xs.length > 0);
|
||||||
|
|
||||||
const filter = (notes: ScyllaNote[]) => {
|
const filter = (notes: ScyllaNote[]) => {
|
||||||
let filtered = filterVisibility(notes, user, followingUserIds);
|
let filtered = notes.filter(note => note.visibility !== "home");
|
||||||
|
filtered = filterVisibility(filtered, user, followingUserIds);
|
||||||
filtered = filterReply(filtered, antenna.withReplies, user);
|
filtered = filterReply(filtered, antenna.withReplies, user);
|
||||||
filtered = filterMutedUser(
|
filtered = filterMutedUser(
|
||||||
filtered,
|
filtered,
|
||||||
|
|
|
@ -33,8 +33,6 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js";
|
||||||
import renderNote from "@/remote/activitypub/renderer/note.js";
|
import renderNote from "@/remote/activitypub/renderer/note.js";
|
||||||
import renderUpdate from "@/remote/activitypub/renderer/update.js";
|
import renderUpdate from "@/remote/activitypub/renderer/update.js";
|
||||||
import { deliverToRelays } from "@/services/relay.js";
|
import { deliverToRelays } from "@/services/relay.js";
|
||||||
// import { deliverQuestionUpdate } from "@/services/note/polls/update.js";
|
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
|
||||||
import {
|
import {
|
||||||
type ScyllaNote,
|
type ScyllaNote,
|
||||||
type ScyllaPoll,
|
type ScyllaPoll,
|
||||||
|
@ -690,6 +688,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
newScyllaNote.id,
|
newScyllaNote.id,
|
||||||
scyllaNote.visibility,
|
scyllaNote.visibility,
|
||||||
newScyllaNote.text,
|
newScyllaNote.text,
|
||||||
|
newScyllaNote.lang,
|
||||||
newScyllaNote.name,
|
newScyllaNote.name,
|
||||||
newScyllaNote.cw,
|
newScyllaNote.cw,
|
||||||
newScyllaNote.localOnly,
|
newScyllaNote.localOnly,
|
||||||
|
|
|
@ -360,6 +360,8 @@ export default async (
|
||||||
|
|
||||||
const note = await insertNote(user, data, tags, emojis, mentionedUsers);
|
const note = await insertNote(user, data, tags, emojis, mentionedUsers);
|
||||||
|
|
||||||
|
if (!note) return rej("empty note");
|
||||||
|
|
||||||
res(note);
|
res(note);
|
||||||
|
|
||||||
// 統計を更新
|
// 統計を更新
|
||||||
|
@ -877,12 +879,24 @@ async function insertNote(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip insertion if the post is empty
|
||||||
|
if (
|
||||||
|
!insert.text && // no content
|
||||||
|
!insert.hasPoll && // no poll
|
||||||
|
(!data.files || data.files.length === 0) && // no files
|
||||||
|
!insert.replyId && // no reply
|
||||||
|
!insert.renoteId // no boost
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const params = [
|
const params = [
|
||||||
insert.createdAt,
|
insert.createdAt,
|
||||||
insert.createdAt,
|
insert.createdAt,
|
||||||
insert.id,
|
insert.id,
|
||||||
insert.visibility,
|
insert.visibility,
|
||||||
insert.text,
|
insert.text,
|
||||||
|
insert.lang,
|
||||||
insert.name,
|
insert.name,
|
||||||
insert.cw,
|
insert.cw,
|
||||||
insert.localOnly,
|
insert.localOnly,
|
||||||
|
|
Loading…
Reference in a new issue