Compare commits
4 commits
0365d2d337
...
9374e4ef93
Author | SHA1 | Date | |
---|---|---|---|
9374e4ef93 | |||
0db57bd423 | |||
9cc05e565b | |||
fe051e8207 |
18 changed files with 158 additions and 131 deletions
|
@ -295,7 +295,7 @@ if (!nativeBinding) {
|
||||||
throw new Error(`Failed to load native binding`)
|
throw new Error(`Failed to load native binding`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { EnvConfig, readEnvironmentConfig, readServerConfig, JsDbConn, connectToDatabase, AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, getFullApAccount, isSelfHost, extractHost, toPuny, toPunyOptional, convertToHiddenPost, sqlLikeEscape, safeForSql, formatMilliseconds, nativeInitIdGenerator, nativeCreateId, nativeGetTimestamp, fetchMeta, metaToPugArgs, hasOtherRenoteOfThisNote, genString, IdConvertType, convertId } = nativeBinding
|
const { EnvConfig, readEnvironmentConfig, readServerConfig, JsDbConn, connectToDatabase, AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, getFullApAccount, isSelfHost, extractHost, toPuny, toPunyOptional, convertToHiddenPost, sqlLikeEscape, safeForSql, formatMilliseconds, nativeInitIdGenerator, nativeCreateId, nativeGetTimestamp, fetchMeta, metaToPugArgs, hasOtherRenoteOfThisNote, nyaify, genString, IdConvertType, convertId } = nativeBinding
|
||||||
|
|
||||||
module.exports.EnvConfig = EnvConfig
|
module.exports.EnvConfig = EnvConfig
|
||||||
module.exports.readEnvironmentConfig = readEnvironmentConfig
|
module.exports.readEnvironmentConfig = readEnvironmentConfig
|
||||||
|
@ -329,6 +329,7 @@ module.exports.nativeGetTimestamp = nativeGetTimestamp
|
||||||
module.exports.fetchMeta = fetchMeta
|
module.exports.fetchMeta = fetchMeta
|
||||||
module.exports.metaToPugArgs = metaToPugArgs
|
module.exports.metaToPugArgs = metaToPugArgs
|
||||||
module.exports.hasOtherRenoteOfThisNote = hasOtherRenoteOfThisNote
|
module.exports.hasOtherRenoteOfThisNote = hasOtherRenoteOfThisNote
|
||||||
|
module.exports.nyaify = nyaify
|
||||||
module.exports.genString = genString
|
module.exports.genString = genString
|
||||||
module.exports.IdConvertType = IdConvertType
|
module.exports.IdConvertType = IdConvertType
|
||||||
module.exports.convertId = convertId
|
module.exports.convertId = convertId
|
||||||
|
|
1
packages/backend-rs/Cargo.lock
generated
1
packages/backend-rs/Cargo.lock
generated
|
@ -214,6 +214,7 @@ dependencies = [
|
||||||
"parse-display",
|
"parse-display",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"rand",
|
"rand",
|
||||||
|
"regex",
|
||||||
"schemars",
|
"schemars",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -20,6 +20,7 @@ jsonschema = "0.17.1"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
parse-display = "0.8.2"
|
parse-display = "0.8.2"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
regex = "1.10.3"
|
||||||
schemars = { version = "0.8.16", features = ["chrono"] }
|
schemars = { version = "0.8.16", features = ["chrono"] }
|
||||||
sea-orm = { version = "0.12.12", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
sea-orm = { version = "0.12.12", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi)]
|
#[napi_derive::napi]
|
||||||
pub struct EnvConfig {
|
pub struct EnvConfig {
|
||||||
pub only_queue: bool,
|
pub only_queue: bool,
|
||||||
pub only_server: bool,
|
pub only_server: bool,
|
||||||
|
@ -10,7 +10,7 @@ pub struct EnvConfig {
|
||||||
pub slow: bool,
|
pub slow: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi)]
|
#[napi_derive::napi]
|
||||||
pub fn read_environment_config() -> EnvConfig {
|
pub fn read_environment_config() -> EnvConfig {
|
||||||
let node_env = std::env::var("NODE_ENV").unwrap_or_default().to_lowercase();
|
let node_env = std::env::var("NODE_ENV").unwrap_or_default().to_lowercase();
|
||||||
let is_testing = node_env == "test" || node_env == "testing";
|
let is_testing = node_env == "test" || node_env == "testing";
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_yaml;
|
use serde_yaml;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
|
#[napi_derive::napi(object)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub db: DbConfig,
|
pub db: DbConfig,
|
||||||
|
@ -13,8 +14,8 @@ pub struct ServerConfig {
|
||||||
pub cache_server: Option<RedisConfig>,
|
pub cache_server: Option<RedisConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
|
#[napi_derive::napi(object)]
|
||||||
pub struct DbConfig {
|
pub struct DbConfig {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub port: u32,
|
pub port: u32,
|
||||||
|
@ -23,8 +24,8 @@ pub struct DbConfig {
|
||||||
pub pass: String,
|
pub pass: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
|
#[napi_derive::napi(object)]
|
||||||
pub struct RedisConfig {
|
pub struct RedisConfig {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub port: u32,
|
pub port: u32,
|
||||||
|
@ -37,18 +38,20 @@ pub struct RedisConfig {
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
|
#[napi_derive::napi(object)]
|
||||||
pub struct TlsConfig {
|
pub struct TlsConfig {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub reject_unauthorized: bool,
|
pub reject_unauthorized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "napi", napi_derive::napi)]
|
#[napi_derive::napi]
|
||||||
pub fn read_server_config() -> ServerConfig {
|
pub fn read_server_config() -> ServerConfig {
|
||||||
let cwd = env::current_dir().unwrap();
|
let cwd = env::current_dir().unwrap();
|
||||||
let yml = fs::File::open(cwd.join("../../.config/default.yml"))
|
let yml = fs::File::open(cwd.join("../../.config/default.yml"))
|
||||||
.expect("Failed to open '.config/default.yml'");
|
.expect("Failed to open '.config/default.yml'");
|
||||||
serde_yaml::from_reader(yml).expect("Failed to parse yaml")
|
serde_yaml::from_reader(yml).expect("Failed to parse yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub static SERVER_CONFIG: Lazy<ServerConfig> = Lazy::new(read_server_config);
|
||||||
|
|
40
packages/backend-rs/src/database/connect.rs
Normal file
40
packages/backend-rs/src/database/connect.rs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
use crate::config::server::SERVER_CONFIG;
|
||||||
|
use crate::database::NapiDbErrExt;
|
||||||
|
use sea_orm::{Database, DbConn};
|
||||||
|
use urlencoding::encode;
|
||||||
|
|
||||||
|
#[napi_derive::napi]
|
||||||
|
pub struct JsDbConn {
|
||||||
|
inner: DbConn,
|
||||||
|
}
|
||||||
|
impl JsDbConn {
|
||||||
|
pub fn inner(&self) -> &DbConn {
|
||||||
|
&self.inner
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[napi_derive::napi]
|
||||||
|
pub async fn connect_to_database() -> napi::Result<JsDbConn> {
|
||||||
|
let conn_uri = format!(
|
||||||
|
"postgres://{}:{}@{}:{}/{}",
|
||||||
|
SERVER_CONFIG.db.user,
|
||||||
|
encode(&SERVER_CONFIG.db.pass),
|
||||||
|
SERVER_CONFIG.db.host,
|
||||||
|
SERVER_CONFIG.db.port,
|
||||||
|
SERVER_CONFIG.db.db,
|
||||||
|
);
|
||||||
|
let conn = Database::connect(conn_uri)
|
||||||
|
.await
|
||||||
|
.map_err(NapiDbErrExt::into)?;
|
||||||
|
Ok(JsDbConn { inner: conn })
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod unit_test {
|
||||||
|
use super::connect_to_database;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn connect_test() {
|
||||||
|
assert!(connect_to_database().await.is_ok());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,50 +1,5 @@
|
||||||
|
pub mod connect;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
||||||
|
pub use connect::JsDbConn;
|
||||||
pub use error::NapiDbErrExt;
|
pub use error::NapiDbErrExt;
|
||||||
|
|
||||||
use crate::config::server::DbConfig;
|
|
||||||
use sea_orm::{Database, DbConn};
|
|
||||||
use urlencoding::encode;
|
|
||||||
|
|
||||||
#[napi_derive::napi]
|
|
||||||
pub struct JsDbConn {
|
|
||||||
inner: DbConn,
|
|
||||||
}
|
|
||||||
impl JsDbConn {
|
|
||||||
pub fn inner(&self) -> &DbConn {
|
|
||||||
&self.inner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi_derive::napi]
|
|
||||||
pub async fn connect_to_database(config: DbConfig) -> napi::Result<JsDbConn> {
|
|
||||||
let conn_uri = format!(
|
|
||||||
"postgres://{}:{}@{}:{}/{}",
|
|
||||||
config.user,
|
|
||||||
encode(&config.pass),
|
|
||||||
config.host,
|
|
||||||
config.port,
|
|
||||||
config.db,
|
|
||||||
);
|
|
||||||
let conn = Database::connect(conn_uri)
|
|
||||||
.await
|
|
||||||
.map_err(NapiDbErrExt::into)?;
|
|
||||||
Ok(JsDbConn { inner: conn })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod unit_test {
|
|
||||||
use super::connect_to_database;
|
|
||||||
use crate::config::server::read_server_config;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn connect_with_server_config() {
|
|
||||||
assert!(connect_to_database(read_server_config().db).await.is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn connect_with_incorrect_password() {
|
|
||||||
let mut config = read_server_config().db;
|
|
||||||
config.pass.push('.'); // password should be incorrect now
|
|
||||||
assert!(connect_to_database(config).await.is_err());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
use crate::config::server::ServerConfig;
|
use crate::config::server::SERVER_CONFIG;
|
||||||
use idna;
|
use idna;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[napi_derive::napi]
|
#[napi_derive::napi]
|
||||||
pub fn get_full_ap_account(
|
pub fn get_full_ap_account(username: String, host: Option<String>) -> String {
|
||||||
server_config: ServerConfig,
|
|
||||||
username: String,
|
|
||||||
host: Option<String>,
|
|
||||||
) -> String {
|
|
||||||
if host.is_none() {
|
if host.is_none() {
|
||||||
format!("{}@{}", username, extract_host(server_config.url))
|
format!("{}@{}", username, extract_host(SERVER_CONFIG.url.clone()))
|
||||||
} else {
|
} else {
|
||||||
format!("{}@{}", username, to_puny(host.unwrap()))
|
format!("{}@{}", username, to_puny(host.unwrap()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi_derive::napi]
|
#[napi_derive::napi]
|
||||||
pub fn is_self_host(server_config: ServerConfig, host: Option<String>) -> bool {
|
pub fn is_self_host(host: Option<String>) -> bool {
|
||||||
if let Some(x) = host {
|
if let Some(x) = host {
|
||||||
extract_host(server_config.url) == to_puny(x)
|
extract_host(SERVER_CONFIG.url.clone()) == to_puny(x)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,5 @@ pub mod format_milliseconds;
|
||||||
pub mod id;
|
pub mod id;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
pub mod note;
|
pub mod note;
|
||||||
|
pub mod nyaify;
|
||||||
pub mod random;
|
pub mod random;
|
||||||
|
|
84
packages/backend-rs/src/util/nyaify.rs
Normal file
84
packages/backend-rs/src/util/nyaify.rs
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use regex::{Captures, Regex};
|
||||||
|
|
||||||
|
#[napi_derive::napi]
|
||||||
|
pub fn nyaify(text: String, lang: Option<String>, append_miao: bool) -> String {
|
||||||
|
let mut to_return = text.clone();
|
||||||
|
|
||||||
|
{
|
||||||
|
static RE: Lazy<Regex> =
|
||||||
|
Lazy::new(|| Regex::new(r"(?i-u)(non)([bcdfghjklmnpqrstvwxyz])").unwrap());
|
||||||
|
to_return = RE
|
||||||
|
.replace_all(&to_return, |caps: &Captures<'_>| {
|
||||||
|
format!(
|
||||||
|
"{}{}",
|
||||||
|
match &caps[1] {
|
||||||
|
"non" => "nyan",
|
||||||
|
"Non" => "Nyan",
|
||||||
|
"NON" => "NYAN",
|
||||||
|
_ => &caps[1],
|
||||||
|
},
|
||||||
|
&caps[2]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"다([..。…??!!\s]|$)").unwrap());
|
||||||
|
to_return = RE.replace_all(&to_return, r"다냥$1").to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"야([??\s]|$)").unwrap());
|
||||||
|
to_return = RE.replace_all(&to_return, r"냥$1").to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"([나-낳])").unwrap());
|
||||||
|
to_return = RE
|
||||||
|
.replace_all(&to_return, |caps: &Captures<'_>| {
|
||||||
|
format!(
|
||||||
|
"{}",
|
||||||
|
char::from_u32(
|
||||||
|
caps[0].chars().next().unwrap() as u32 + 56 /* = '냐' - '나' */
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
if lang.is_some() && lang.unwrap().starts_with("zh") {
|
||||||
|
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"[妙庙描渺瞄秒苗藐廟]").unwrap());
|
||||||
|
to_return = RE.replace_all(&to_return, "喵").to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
let simple_rules = [
|
||||||
|
("な", "にゃ"),
|
||||||
|
("ナ", "ニャ"),
|
||||||
|
("ナ", "ニャ"),
|
||||||
|
("na", "nya"),
|
||||||
|
("NA", "NYA"),
|
||||||
|
("Na", "Nya"),
|
||||||
|
("morning", "mornyan"),
|
||||||
|
("Morning", "Mornyan"),
|
||||||
|
("MORNING", "MORNYAN"),
|
||||||
|
("everyone", "everynyan"),
|
||||||
|
("Everyone", "Everynyan"),
|
||||||
|
("EVERYONE", "EVERYNYAN"),
|
||||||
|
("να", "νια"),
|
||||||
|
("ΝΑ", "ΝΙΑ"),
|
||||||
|
("Να", "Νια"),
|
||||||
|
];
|
||||||
|
|
||||||
|
simple_rules.into_iter().for_each(|(from, to)| {
|
||||||
|
to_return = to_return.replace(from, to);
|
||||||
|
});
|
||||||
|
|
||||||
|
if append_miao {
|
||||||
|
to_return.push('喵');
|
||||||
|
}
|
||||||
|
|
||||||
|
to_return
|
||||||
|
}
|
|
@ -3,18 +3,16 @@ import {
|
||||||
readEnvironmentConfig,
|
readEnvironmentConfig,
|
||||||
connectToDatabase,
|
connectToDatabase,
|
||||||
fetchMeta as fetchMetaImpl,
|
fetchMeta as fetchMetaImpl,
|
||||||
getFullApAccount as getFullApAccountImpl,
|
|
||||||
hasOtherRenoteOfThisNote as hasOtherRenoteOfThisNoteImpl,
|
hasOtherRenoteOfThisNote as hasOtherRenoteOfThisNoteImpl,
|
||||||
isSelfHost as isSelfHostImpl,
|
|
||||||
JsDbConn,
|
JsDbConn,
|
||||||
} from "backend-rs";
|
} from "backend-rs";
|
||||||
|
|
||||||
export const serverConfig = readServerConfig();
|
export const serverConfig = readServerConfig();
|
||||||
export const envConfig = readEnvironmentConfig();
|
export const envConfig = readEnvironmentConfig();
|
||||||
const dbPromise = connectToDatabase(serverConfig.db);
|
|
||||||
|
|
||||||
type Option<T> = T | null | undefined;
|
type Option<T> = T | null | undefined;
|
||||||
|
|
||||||
|
const dbPromise = connectToDatabase();
|
||||||
const curryDb =
|
const curryDb =
|
||||||
<P extends any[], R>(f: (db: JsDbConn, ...args: P) => Promise<R>) =>
|
<P extends any[], R>(f: (db: JsDbConn, ...args: P) => Promise<R>) =>
|
||||||
(...args: P) =>
|
(...args: P) =>
|
||||||
|
@ -22,14 +20,3 @@ const curryDb =
|
||||||
|
|
||||||
export const fetchMeta = curryDb(fetchMetaImpl);
|
export const fetchMeta = curryDb(fetchMetaImpl);
|
||||||
export const hasOtherRenoteOfThisNote = curryDb(hasOtherRenoteOfThisNoteImpl);
|
export const hasOtherRenoteOfThisNote = curryDb(hasOtherRenoteOfThisNoteImpl);
|
||||||
|
|
||||||
export function getFullApAccount(
|
|
||||||
username: string,
|
|
||||||
host: Option<string>,
|
|
||||||
): string {
|
|
||||||
return getFullApAccountImpl(serverConfig, username, host);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isSelfHost(host: Option<string>): boolean {
|
|
||||||
return isSelfHostImpl(serverConfig, host);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ import type { Antenna } from "@/models/entities/antenna.js";
|
||||||
import type { Note } from "@/models/entities/note.js";
|
import type { Note } from "@/models/entities/note.js";
|
||||||
import type { User } from "@/models/entities/user.js";
|
import type { User } from "@/models/entities/user.js";
|
||||||
import { Blockings, Followings, UserProfiles } from "@/models/index.js";
|
import { Blockings, Followings, UserProfiles } from "@/models/index.js";
|
||||||
import { getFullApAccount } from "@/misc/backend-rs.js";
|
import { getFullApAccount, stringToAcct } from "backend-rs";
|
||||||
import { stringToAcct } from "backend-rs";
|
|
||||||
import type { Packed } from "@/misc/schema.js";
|
import type { Packed } from "@/misc/schema.js";
|
||||||
import { Cache } from "@/misc/cache.js";
|
import { Cache } from "@/misc/cache.js";
|
||||||
import { getWordHardMute } from "@/misc/check-word-mute.js";
|
import { getWordHardMute } from "@/misc/check-word-mute.js";
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
export default function (
|
|
||||||
text: string,
|
|
||||||
lang: string | undefined,
|
|
||||||
appendMiao: boolean,
|
|
||||||
): string {
|
|
||||||
text = text
|
|
||||||
// ja-JP
|
|
||||||
.replaceAll("な", "にゃ")
|
|
||||||
.replaceAll("ナ", "ニャ")
|
|
||||||
.replaceAll("ナ", "ニャ")
|
|
||||||
// en-US
|
|
||||||
.replaceAll("na", "nya")
|
|
||||||
.replaceAll("Na", "Nya")
|
|
||||||
.replaceAll("NA", "NYA")
|
|
||||||
.replace(/(?<=morn)ing/gi, (x) => (x === "ING" ? "YAN" : "yan"))
|
|
||||||
.replace(/(?<=every)one/gi, (x) => (x === "ONE" ? "NYAN" : "nyan"))
|
|
||||||
.replace(/non(?=[bcdfghjklmnpqrstvwxyz])/gi, (x) =>
|
|
||||||
x === "NON" ? "NYAN" : "nyan",
|
|
||||||
)
|
|
||||||
// ko-KR
|
|
||||||
.replace(/[나-낳]/g, (match) =>
|
|
||||||
String.fromCharCode(
|
|
||||||
match.charCodeAt(0)! + "냐".charCodeAt(0) - "나".charCodeAt(0),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.replace(/(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm, "다냥")
|
|
||||||
.replace(/(야(?=\?))|(야$)|(야(?= ))/gm, "냥")
|
|
||||||
// el-GR
|
|
||||||
.replaceAll("να", "νια")
|
|
||||||
.replaceAll("ΝΑ", "ΝΙΑ")
|
|
||||||
.replaceAll("Να", "Νια");
|
|
||||||
|
|
||||||
// zh-CN, zh-TW
|
|
||||||
if (lang === "zh") text = text.replace(/(妙|庙|描|渺|瞄|秒|苗|藐|廟)/g, "喵");
|
|
||||||
if (appendMiao) text += "喵";
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
|
@ -3,8 +3,7 @@ import { Emojis } from "@/models/index.js";
|
||||||
import type { Emoji } from "@/models/entities/emoji.js";
|
import type { Emoji } from "@/models/entities/emoji.js";
|
||||||
import type { Note } from "@/models/entities/note.js";
|
import type { Note } from "@/models/entities/note.js";
|
||||||
import { Cache } from "./cache.js";
|
import { Cache } from "./cache.js";
|
||||||
import { toPunyOptional } from "backend-rs";
|
import { isSelfHost, toPunyOptional } from "backend-rs";
|
||||||
import { isSelfHost } from "@/misc/backend-rs.js";
|
|
||||||
import { decodeReaction } from "./reaction-lib.js";
|
import { decodeReaction } from "./reaction-lib.js";
|
||||||
import config from "@/config/index.js";
|
import config from "@/config/index.js";
|
||||||
import { query } from "@/prelude/url.js";
|
import { query } from "@/prelude/url.js";
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
Channels,
|
Channels,
|
||||||
} from "../index.js";
|
} from "../index.js";
|
||||||
import type { Packed } from "@/misc/schema.js";
|
import type { Packed } from "@/misc/schema.js";
|
||||||
import nyaify from "@/misc/nyaify.js";
|
import { nyaify } from "backend-rs";
|
||||||
import { awaitAll } from "@/prelude/await-all.js";
|
import { awaitAll } from "@/prelude/await-all.js";
|
||||||
import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js";
|
import { convertReactions, decodeReaction } from "@/misc/reaction-lib.js";
|
||||||
import type { NoteReaction } from "@/models/entities/note-reaction.js";
|
import type { NoteReaction } from "@/models/entities/note-reaction.js";
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import type { CacheableRemoteUser } from "@/models/entities/user.js";
|
import type { CacheableRemoteUser } from "@/models/entities/user.js";
|
||||||
import type { IRead } from "../type.js";
|
import type { IRead } from "../type.js";
|
||||||
import { getApId } from "../type.js";
|
import { getApId } from "../type.js";
|
||||||
import { extractHost } from "backend-rs";
|
import { extractHost, isSelfHost } from "backend-rs";
|
||||||
import { isSelfHost } from "@/misc/backend-rs.js";
|
|
||||||
import { MessagingMessages } from "@/models/index.js";
|
import { MessagingMessages } from "@/models/index.js";
|
||||||
import { readUserMessagingMessage } from "@/server/api/common/read-messaging-message.js";
|
import { readUserMessagingMessage } from "@/server/api/common/read-messaging-message.js";
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@ import { getJson } from "@/misc/fetch.js";
|
||||||
import type { ILocalUser } from "@/models/entities/user.js";
|
import type { ILocalUser } from "@/models/entities/user.js";
|
||||||
import { getInstanceActor } from "@/services/instance-actor.js";
|
import { getInstanceActor } from "@/services/instance-actor.js";
|
||||||
import { fetchMeta } from "@/misc/backend-rs.js";
|
import { fetchMeta } from "@/misc/backend-rs.js";
|
||||||
import { extractHost } from "backend-rs";
|
import { extractHost, isSelfHost } from "backend-rs";
|
||||||
import { isSelfHost } from "@/misc/backend-rs.js";
|
|
||||||
import { signedGet } from "./request.js";
|
import { signedGet } from "./request.js";
|
||||||
import type { IObject, ICollection, IOrderedCollection } from "./type.js";
|
import type { IObject, ICollection, IOrderedCollection } from "./type.js";
|
||||||
import { isCollectionOrOrderedCollection, getApId } from "./type.js";
|
import { isCollectionOrOrderedCollection, getApId } from "./type.js";
|
||||||
|
|
|
@ -9,7 +9,7 @@ import renderKey from "@/remote/activitypub/renderer/key.js";
|
||||||
import { renderPerson } from "@/remote/activitypub/renderer/person.js";
|
import { renderPerson } from "@/remote/activitypub/renderer/person.js";
|
||||||
import renderEmoji from "@/remote/activitypub/renderer/emoji.js";
|
import renderEmoji from "@/remote/activitypub/renderer/emoji.js";
|
||||||
import { inbox as processInbox } from "@/queue/index.js";
|
import { inbox as processInbox } from "@/queue/index.js";
|
||||||
import { isSelfHost } from "@/misc/backend-rs.js";
|
import { isSelfHost } from "backend-rs";
|
||||||
import {
|
import {
|
||||||
Notes,
|
Notes,
|
||||||
Users,
|
Users,
|
||||||
|
|
Loading…
Reference in a new issue