Compare commits

...

10 Commits

100 changed files with 7326 additions and 147 deletions

View File

@ -0,0 +1,50 @@
name: Docker Image CI
on:
push:
branches:
- main
permissions:
actions: read
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
uses: docker/login-action@v2
with:
registry: git.astolfo.cool
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: git.astolfo.cool/natty/magnetar:${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
/target /target
.idea .idea
.vscode .vscode
/.env

1767
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,17 +2,23 @@
name = "magnetar" name = "magnetar"
description = "An exploratory ActivityPub project" description = "An exploratory ActivityPub project"
version = "0.1.0" version = "0.1.0"
license = "APGL" license = "AGPL-3.0-only"
edition = "2021" edition = "2021"
[workspace] [workspace]
members = [ members = [
".", ".",
"ext_nodeinfo",
"ext_webfinger",
"ext_calckey_model",
"core" "core"
] ]
[dependencies] [dependencies]
magnetar_core = { path = "./core", version = "0.1" } magnetar_core = { path = "./core", version = "0.1" }
magnetar_webfinger = { path = "./ext_webfinger", version = "0.1"}
magnetar_nodeinfo = { path = "./ext_nodeinfo", version = "0.1"}
magnetar_calckey_model = { path = "./ext_calckey_model", version = "0.1" }
anyhow = "1.0" anyhow = "1.0"
@ -22,9 +28,18 @@ axum = "0.6"
hyper = { version = "0.14", features = ["full"] } hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1.24", features = ["full"] } tokio = { version = "1.24", features = ["full"] }
tower = "0.4" tower = "0.4"
tower-http = { version = "0.3", features = ["cors", "trace"] } tower-http = { version = "0.4", features = ["cors", "trace"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = "0.1" tracing = "0.1"
serde = { version = "1.0", features = ["derive"] } ring = "0.16"
rand = { version = "0.8", features = ["getrandom"] }
rsa = "0.8"
percent-encoding = "2.2"
serde = { version = "1.0", features = ["derive"] }
toml = "0.7"
serde_json = "1.0"

39
Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM docker.io/rust:1.69-bullseye as build
RUN update-ca-certificates
ENV USER=magnetar
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR /magnetar
COPY ./ .
RUN cargo build --release
FROM docker.io/debian:bullseye-slim
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group
WORKDIR /magnetar
RUN chown -R 10001:10001 .
COPY --from=build /magnetar/target/release/magnetar ./
USER magnetar:magnetar
EXPOSE 4939/tcp
CMD ["/magnetar/magnetar"]

3
config/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!.gitignore
!default.toml

86
config/default.toml Normal file
View File

@ -0,0 +1,86 @@
# Primary Magnetar configuration.
# The location of the config to load may be overriden with MAG_CONFIG_PATH.
# Please note options in this file take priority over environment variables.
# Container quick start:
# Technically it's not necessary to edit this file at all.
# Set the following variables:
# - MAG_C_HOST (host)
# - MAG_C_DATABASE_URL (Postgres database connection URL)
# --------------------------------[ LOGGING ]----------------------------------
# Logging can be configured using the RUST_LOG environment variable.
# See https://docs.rs/env_logger/0.10.0/env_logger/#enabling-logging
# Default: "info"
# -------------------------------[ NETWORKING ]--------------------------------
# Magnetar does not contain a TLS ingress, please use a reverse proxy like:
# - Nginx (https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/)
# - Caddy (https://caddyserver.com/docs/quick-starts/reverse-proxy)
# - Traefik
# [REQUIRED]
# The hostname the instance will run on.
# Environment variable: MAG_C_HOST
# networking.host = "example.com"
# [Optional]
# The port of the instance.
# Default: 4939
# Environment variable: MAG_C_PORT
# networking.port = 4939
# [Optional]
# The protocol to use for the instance.
# Possible values: "http", "https"
# Default: "https"
# Environment variable: MAG_C_PROTOCOL
# networking.protocol = "https"
# [Optional]
# The IP address the application will bind to.
# Default: "::"
# Environment variable: MAG_C_BIND_ADDR
# networking.bind_addr = "::"
# ----------------------------------[ DATA ]-----------------------------------
# [REQUIRED]
# An URL pointing to a Postgres database, with a Calckey database
# Environment variables: MAG_C_DATABASE_URL, DATABASE_URL
# data.database_url = "postgres://username:password@db:5432/calckey"
# -------------------------------[ FEDERATION ]--------------------------------
# --------------------------------[ BRANDING ]---------------------------------
# [Optional]
# The name of this software
# Default: "magnetar"
# Environment variable: MAG_C_BR_NAME
# branding.name = "magnetar"
# [Optional]
# The version of this software
# Default: <the version the software was compiled with>
# Environment variable: MAG_C_BR_VERSION
# branding.version = "0.1"
# [Optional]
# The homepage of this software
# Default: "https://git.astolfo.cool/natty/magnetar"
# Environment variable: MAG_C_BR_HOMEPAGE
# branding.homepage = "https://git.astolfo.cool/natty/magnetar"
# [Optional]
# The repository of this software
# Default: "https://git.astolfo.cool/natty/magnetar"
# Environment variable: MAG_C_BR_REPOSITORY
# branding.repository = "https://git.astolfo.cool/natty/magnetar"

View File

@ -2,7 +2,7 @@
name = "magnetar_core" name = "magnetar_core"
description = "A library to power an exploratory ActivityPub project" description = "A library to power an exploratory ActivityPub project"
version = "0.1.0" version = "0.1.0"
license = "APGL" license = "AGPL-3.0-only"
edition = "2021" edition = "2021"
[lib] [lib]

View File

@ -0,0 +1,70 @@
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::{Borrow, Cow};
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Acct(String);
impl Acct {
pub fn new(uri_without_acct: Cow<'_, str>) -> Self {
Acct(uri_without_acct.to_string())
}
}
impl<S: Borrow<str>> From<S> for Acct {
fn from(value: S) -> Self {
let val = value.borrow();
Acct(val.strip_prefix("acct:").unwrap_or(val).to_string())
}
}
impl AsRef<str> for Acct {
fn as_ref(&self) -> &str {
&self.0
}
}
impl Serialize for Acct {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&format!("acct:{}", self.0))
}
}
impl<'de> Deserialize<'de> for Acct {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let acct = String::deserialize(deserializer)?;
if let Some(rem) = acct.strip_prefix("acct:") {
Ok(Acct(rem.to_owned()))
} else {
Err(de::Error::custom(
"Missing acct protocol for account!".to_owned(),
))
}
}
}
#[cfg(test)]
mod test {
use crate::web_model::acct::Acct;
use serde_json::json;
#[test]
fn should_remove_acct_prefix() {
let json = json!("acct:natty@tech.lgbt");
let acct: Acct = serde_json::from_value(json).unwrap();
assert_eq!(acct, Acct::from("natty@tech.lgbt"))
}
#[test]
fn should_add_acct_prefix() {
let acct = Acct::from("natty@tech.lgbt");
let json = serde_json::to_value(acct).unwrap();
assert_eq!(json, json!("acct:natty@tech.lgbt"));
}
}

View File

@ -4,10 +4,10 @@ use serde_json::Value;
use std::fmt::Debug; use std::fmt::Debug;
use std::str::FromStr; use std::str::FromStr;
pub mod acct;
pub mod activity_streams; pub mod activity_streams;
pub mod webfinger;
trait ContentType: Serialize { pub trait ContentType: Serialize {
fn mime_type(&self) -> &'static str; fn mime_type(&self) -> &'static str;
} }
@ -58,6 +58,7 @@ pub mod content_type {
content_type!(pub ContentActivityStreams, "application/activity+json"); content_type!(pub ContentActivityStreams, "application/activity+json");
content_type!(pub ContentHtml, "text/html"); content_type!(pub ContentHtml, "text/html");
content_type!(pub ContentJson, "application/json"); content_type!(pub ContentJson, "application/json");
content_type!(pub ContentJrdJson, "application/jrd+json");
content_type!(pub ContentMultipartFormData, "multipart/form-data"); content_type!(pub ContentMultipartFormData, "multipart/form-data");
content_type!(pub ContentUrlEncoded, "application/x-www-form-urlencoded"); content_type!(pub ContentUrlEncoded, "application/x-www-form-urlencoded");
} }
@ -101,7 +102,7 @@ macro_rules! link_rel {
}; };
} }
trait Rel: Serialize { pub trait Rel: Serialize {
fn rel(&self) -> &'static str; fn rel(&self) -> &'static str;
} }
@ -113,6 +114,8 @@ pub mod rel {
link_rel!(pub RelWebFingerProfilePage, "http://webfinger.net/rel/profile-page"); link_rel!(pub RelWebFingerProfilePage, "http://webfinger.net/rel/profile-page");
link_rel!(pub RelSelf, "self"); link_rel!(pub RelSelf, "self");
link_rel!(pub RelOStatusSubscribe, "http://ostatus.org/schema/1.0/subscribe"); link_rel!(pub RelOStatusSubscribe, "http://ostatus.org/schema/1.0/subscribe");
link_rel!(pub RelNodeInfo20, "http://nodeinfo.diaspora.software/ns/schema/2.0");
link_rel!(pub RelNodeInfo21, "http://nodeinfo.diaspora.software/ns/schema/2.1");
} }
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]

View File

@ -0,0 +1,19 @@
[package]
name = "magnetar_calckey_model"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["rlib"]
[dependencies]
ck = { path = "./entity_ck" }
anyhow = "1"
dotenvy = "0.15"
log = "0.4"
tokio = { version = "1.24", features = ["full"] }
sea-orm = { version = "0.11", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
chrono = "0.4"

View File

@ -0,0 +1,9 @@
[package]
name = "ck"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
sea-orm = { version = "0.11", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros", "postgres-array"] }
serde = { version = "1.0", features = ["derive"] }

View File

@ -0,0 +1,55 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "abuse_user_report")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "targetUserId")]
pub target_user_id: String,
#[sea_orm(column_name = "reporterId")]
pub reporter_id: String,
#[sea_orm(column_name = "assigneeId")]
pub assignee_id: Option<String>,
pub resolved: bool,
pub comment: String,
#[sea_orm(column_name = "targetUserHost")]
pub target_user_host: Option<String>,
#[sea_orm(column_name = "reporterHost")]
pub reporter_host: Option<String>,
pub forwarded: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::ReporterId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User3,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::AssigneeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::TargetUserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,69 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "access_token")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub token: String,
pub hash: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "appId")]
pub app_id: Option<String>,
#[sea_orm(column_name = "lastUsedAt")]
pub last_used_at: Option<DateTimeWithTimeZone>,
pub session: Option<String>,
pub name: Option<String>,
pub description: Option<String>,
#[sea_orm(column_name = "iconUrl")]
pub icon_url: Option<String>,
pub permission: Vec<String>,
pub fetched: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::app::Entity",
from = "Column::AppId",
to = "super::app::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
App,
#[sea_orm(has_many = "super::notification::Entity")]
Notification,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::app::Entity> for Entity {
fn to() -> RelationDef {
Relation::App.def()
}
}
impl Related<super::notification::Entity> for Entity {
fn to() -> RelationDef {
Relation::Notification.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,26 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "ad")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: DateTimeWithTimeZone,
pub place: String,
pub priority: String,
pub url: String,
#[sea_orm(column_name = "imageUrl")]
pub image_url: String,
pub memo: String,
pub ratio: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,32 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub text: String,
pub title: String,
#[sea_orm(column_name = "imageUrl")]
pub image_url: Option<String>,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::announcement_read::Entity")]
AnnouncementRead,
}
impl Related<super::announcement_read::Entity> for Entity {
fn to() -> RelationDef {
Relation::AnnouncementRead.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement_read")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "announcementId")]
pub announcement_id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::announcement::Entity",
from = "Column::AnnouncementId",
to = "super::announcement::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Announcement,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::announcement::Entity> for Entity {
fn to() -> RelationDef {
Relation::Announcement.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,90 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::AntennaSrcEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "antenna")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
pub src: AntennaSrcEnum,
#[sea_orm(column_name = "userListId")]
pub user_list_id: Option<String>,
pub keywords: Json,
#[sea_orm(column_name = "withFile")]
pub with_file: bool,
pub expression: Option<String>,
pub notify: bool,
#[sea_orm(column_name = "caseSensitive")]
pub case_sensitive: bool,
#[sea_orm(column_name = "withReplies")]
pub with_replies: bool,
#[sea_orm(column_name = "userGroupJoiningId")]
pub user_group_joining_id: Option<String>,
pub users: Vec<String>,
#[sea_orm(column_name = "excludeKeywords")]
pub exclude_keywords: Json,
pub instances: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::antenna_note::Entity")]
AntennaNote,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(
belongs_to = "super::user_group_joining::Entity",
from = "Column::UserGroupJoiningId",
to = "super::user_group_joining::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroupJoining,
#[sea_orm(
belongs_to = "super::user_list::Entity",
from = "Column::UserListId",
to = "super::user_list::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserList,
}
impl Related<super::antenna_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::AntennaNote.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_group_joining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupJoining.def()
}
}
impl Related<super::user_list::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserList.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,49 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "antenna_note")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
#[sea_orm(column_name = "antennaId")]
pub antenna_id: String,
pub read: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::antenna::Entity",
from = "Column::AntennaId",
to = "super::antenna::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Antenna,
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
}
impl Related<super::antenna::Entity> for Entity {
fn to() -> RelationDef {
Relation::Antenna.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,56 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "app")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
pub secret: String,
pub name: String,
pub description: String,
pub permission: Vec<String>,
#[sea_orm(column_name = "callbackUrl")]
pub callback_url: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::access_token::Entity")]
AccessToken,
#[sea_orm(has_many = "super::auth_session::Entity")]
AuthSession,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
User,
}
impl Related<super::access_token::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessToken.def()
}
}
impl Related<super::auth_session::Entity> for Entity {
fn to() -> RelationDef {
Relation::AuthSession.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,37 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "attestation_challenge")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "userId", primary_key, auto_increment = false)]
pub user_id: String,
pub challenge: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "registrationChallenge")]
pub registration_challenge: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,51 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "auth_session")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub token: String,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
#[sea_orm(column_name = "appId")]
pub app_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::app::Entity",
from = "Column::AppId",
to = "super::app::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
App,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::app::Entity> for Entity {
fn to() -> RelationDef {
Relation::App.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,38 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "blocking")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "blockeeId")]
pub blockee_id: String,
#[sea_orm(column_name = "blockerId")]
pub blocker_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::BlockerId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::BlockeeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,82 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "lastNotedAt")]
pub last_noted_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
pub name: String,
pub description: Option<String>,
#[sea_orm(column_name = "bannerId")]
pub banner_id: Option<String>,
#[sea_orm(column_name = "notesCount")]
pub notes_count: i32,
#[sea_orm(column_name = "usersCount")]
pub users_count: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::channel_following::Entity")]
ChannelFollowing,
#[sea_orm(has_many = "super::channel_note_pining::Entity")]
ChannelNotePining,
#[sea_orm(
belongs_to = "super::drive_file::Entity",
from = "Column::BannerId",
to = "super::drive_file::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
DriveFile,
#[sea_orm(has_many = "super::note::Entity")]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
User,
}
impl Related<super::channel_following::Entity> for Entity {
fn to() -> RelationDef {
Relation::ChannelFollowing.def()
}
}
impl Related<super::channel_note_pining::Entity> for Entity {
fn to() -> RelationDef {
Relation::ChannelNotePining.def()
}
}
impl Related<super::drive_file::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFile.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_following")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]
pub follower_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::channel::Entity",
from = "Column::FolloweeId",
to = "super::channel::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Channel,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FollowerId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_note_pining")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "channelId")]
pub channel_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::channel::Entity",
from = "Column::ChannelId",
to = "super::channel::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Channel,
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,46 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
#[sea_orm(column_name = "isPublic")]
pub is_public: bool,
pub description: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::clip_note::Entity")]
ClipNote,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::clip_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::ClipNote.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,48 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip_note")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
#[sea_orm(column_name = "clipId")]
pub clip_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::clip::Entity",
from = "Column::ClipId",
to = "super::clip::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Clip,
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
}
impl Related<super::clip::Entity> for Entity {
fn to() -> RelationDef {
Relation::Clip.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,112 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_file")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
#[sea_orm(column_name = "userHost")]
pub user_host: Option<String>,
pub md5: String,
pub name: String,
pub r#type: String,
pub size: i32,
pub comment: Option<String>,
pub properties: Json,
#[sea_orm(column_name = "storedInternal")]
pub stored_internal: bool,
pub url: String,
#[sea_orm(column_name = "thumbnailUrl")]
pub thumbnail_url: Option<String>,
#[sea_orm(column_name = "webpublicUrl")]
pub webpublic_url: Option<String>,
#[sea_orm(column_name = "accessKey")]
pub access_key: Option<String>,
#[sea_orm(column_name = "thumbnailAccessKey")]
pub thumbnail_access_key: Option<String>,
#[sea_orm(column_name = "webpublicAccessKey")]
pub webpublic_access_key: Option<String>,
pub uri: Option<String>,
pub src: Option<String>,
#[sea_orm(column_name = "folderId")]
pub folder_id: Option<String>,
#[sea_orm(column_name = "isSensitive")]
pub is_sensitive: bool,
#[sea_orm(column_name = "isLink")]
pub is_link: bool,
pub blurhash: Option<String>,
#[sea_orm(column_name = "webpublicType")]
pub webpublic_type: Option<String>,
#[sea_orm(column_name = "requestHeaders")]
pub request_headers: Option<Json>,
#[sea_orm(column_name = "requestIp")]
pub request_ip: Option<String>,
#[sea_orm(column_name = "maybeSensitive")]
pub maybe_sensitive: bool,
#[sea_orm(column_name = "maybePorn")]
pub maybe_porn: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::channel::Entity")]
Channel,
#[sea_orm(
belongs_to = "super::drive_folder::Entity",
from = "Column::FolderId",
to = "super::drive_folder::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
DriveFolder,
#[sea_orm(has_many = "super::messaging_message::Entity")]
MessagingMessage,
#[sea_orm(has_many = "super::page::Entity")]
Page,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
User,
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::drive_folder::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFolder.def()
}
}
impl Related<super::messaging_message::Entity> for Entity {
fn to() -> RelationDef {
Relation::MessagingMessage.def()
}
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,53 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_folder")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub name: String,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
#[sea_orm(column_name = "parentId")]
pub parent_id: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::drive_file::Entity")]
DriveFile,
#[sea_orm(
belongs_to = "Entity",
from = "Column::ParentId",
to = "Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::drive_file::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFile.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,28 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "emoji")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
pub name: String,
pub host: Option<String>,
#[sea_orm(column_name = "originalUrl")]
pub original_url: String,
pub uri: Option<String>,
pub r#type: Option<String>,
pub aliases: Vec<String>,
pub category: Option<String>,
#[sea_orm(column_name = "publicUrl")]
pub public_url: String,
pub license: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,60 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "follow_request")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]
pub follower_id: String,
#[sea_orm(column_name = "requestId")]
pub request_id: Option<String>,
#[sea_orm(column_name = "followerHost")]
pub follower_host: Option<String>,
#[sea_orm(column_name = "followerInbox")]
pub follower_inbox: Option<String>,
#[sea_orm(column_name = "followerSharedInbox")]
pub follower_shared_inbox: Option<String>,
#[sea_orm(column_name = "followeeHost")]
pub followee_host: Option<String>,
#[sea_orm(column_name = "followeeInbox")]
pub followee_inbox: Option<String>,
#[sea_orm(column_name = "followeeSharedInbox")]
pub followee_shared_inbox: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::notification::Entity")]
Notification,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FolloweeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FollowerId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl Related<super::notification::Entity> for Entity {
fn to() -> RelationDef {
Relation::Notification.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "following")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]
pub follower_id: String,
#[sea_orm(column_name = "followerHost")]
pub follower_host: Option<String>,
#[sea_orm(column_name = "followerInbox")]
pub follower_inbox: Option<String>,
#[sea_orm(column_name = "followerSharedInbox")]
pub follower_shared_inbox: Option<String>,
#[sea_orm(column_name = "followeeHost")]
pub followee_host: Option<String>,
#[sea_orm(column_name = "followeeInbox")]
pub followee_inbox: Option<String>,
#[sea_orm(column_name = "followeeSharedInbox")]
pub followee_shared_inbox: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FolloweeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::FollowerId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_like")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "postId")]
pub post_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::gallery_post::Entity",
from = "Column::PostId",
to = "super::gallery_post::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
GalleryPost,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::gallery_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::GalleryPost.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,53 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_post")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub title: String,
pub description: Option<String>,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
#[sea_orm(column_name = "isSensitive")]
pub is_sensitive: bool,
#[sea_orm(column_name = "likedCount")]
pub liked_count: i32,
pub tags: Vec<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::gallery_like::Entity")]
GalleryLike,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::gallery_like::Entity> for Entity {
fn to() -> RelationDef {
Relation::GalleryLike.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,40 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "hashtag")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub name: String,
#[sea_orm(column_name = "mentionedUserIds")]
pub mentioned_user_ids: Vec<String>,
#[sea_orm(column_name = "mentionedUsersCount")]
pub mentioned_users_count: i32,
#[sea_orm(column_name = "mentionedLocalUserIds")]
pub mentioned_local_user_ids: Vec<String>,
#[sea_orm(column_name = "mentionedLocalUsersCount")]
pub mentioned_local_users_count: i32,
#[sea_orm(column_name = "mentionedRemoteUserIds")]
pub mentioned_remote_user_ids: Vec<String>,
#[sea_orm(column_name = "mentionedRemoteUsersCount")]
pub mentioned_remote_users_count: i32,
#[sea_orm(column_name = "attachedUserIds")]
pub attached_user_ids: Vec<String>,
#[sea_orm(column_name = "attachedUsersCount")]
pub attached_users_count: i32,
#[sea_orm(column_name = "attachedLocalUserIds")]
pub attached_local_user_ids: Vec<String>,
#[sea_orm(column_name = "attachedLocalUsersCount")]
pub attached_local_users_count: i32,
#[sea_orm(column_name = "attachedRemoteUserIds")]
pub attached_remote_user_ids: Vec<String>,
#[sea_orm(column_name = "attachedRemoteUsersCount")]
pub attached_remote_users_count: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,58 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "instance")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "caughtAt")]
pub caught_at: DateTimeWithTimeZone,
pub host: String,
#[sea_orm(column_name = "usersCount")]
pub users_count: i32,
#[sea_orm(column_name = "notesCount")]
pub notes_count: i32,
#[sea_orm(column_name = "followingCount")]
pub following_count: i32,
#[sea_orm(column_name = "followersCount")]
pub followers_count: i32,
#[sea_orm(column_name = "latestRequestSentAt")]
pub latest_request_sent_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "latestStatus")]
pub latest_status: Option<i32>,
#[sea_orm(column_name = "latestRequestReceivedAt")]
pub latest_request_received_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "lastCommunicatedAt")]
pub last_communicated_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "isNotResponding")]
pub is_not_responding: bool,
#[sea_orm(column_name = "softwareName")]
pub software_name: Option<String>,
#[sea_orm(column_name = "softwareVersion")]
pub software_version: Option<String>,
#[sea_orm(column_name = "openRegistrations")]
pub open_registrations: Option<bool>,
pub name: Option<String>,
pub description: Option<String>,
#[sea_orm(column_name = "maintainerName")]
pub maintainer_name: Option<String>,
#[sea_orm(column_name = "maintainerEmail")]
pub maintainer_email: Option<String>,
#[sea_orm(column_name = "infoUpdatedAt")]
pub info_updated_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "isSuspended")]
pub is_suspended: bool,
#[sea_orm(column_name = "iconUrl")]
pub icon_url: Option<String>,
#[sea_orm(column_name = "themeColor")]
pub theme_color: Option<String>,
#[sea_orm(column_name = "faviconUrl")]
pub favicon_url: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,75 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "messaging_message")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "recipientId")]
pub recipient_id: Option<String>,
pub text: Option<String>,
#[sea_orm(column_name = "isRead")]
pub is_read: bool,
#[sea_orm(column_name = "fileId")]
pub file_id: Option<String>,
#[sea_orm(column_name = "groupId")]
pub group_id: Option<String>,
pub reads: Vec<String>,
pub uri: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::drive_file::Entity",
from = "Column::FileId",
to = "super::drive_file::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
DriveFile,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::RecipientId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
#[sea_orm(
belongs_to = "super::user_group::Entity",
from = "Column::GroupId",
to = "super::user_group::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroup,
}
impl Related<super::drive_file::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFile.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,202 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::MetaSensitivemediadetectionEnum;
use super::sea_orm_active_enums::MetaSensitivemediadetectionsensitivityEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "meta")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub name: Option<String>,
pub description: Option<String>,
#[sea_orm(column_name = "maintainerName")]
pub maintainer_name: Option<String>,
#[sea_orm(column_name = "maintainerEmail")]
pub maintainer_email: Option<String>,
#[sea_orm(column_name = "disableRegistration")]
pub disable_registration: bool,
#[sea_orm(column_name = "disableLocalTimeline")]
pub disable_local_timeline: bool,
#[sea_orm(column_name = "disableGlobalTimeline")]
pub disable_global_timeline: bool,
#[sea_orm(column_name = "useStarForReactionFallback")]
pub use_star_for_reaction_fallback: bool,
pub langs: Vec<String>,
#[sea_orm(column_name = "hiddenTags")]
pub hidden_tags: Vec<String>,
#[sea_orm(column_name = "blockedHosts")]
pub blocked_hosts: Vec<String>,
#[sea_orm(column_name = "mascotImageUrl")]
pub mascot_image_url: Option<String>,
#[sea_orm(column_name = "bannerUrl")]
pub banner_url: Option<String>,
#[sea_orm(column_name = "errorImageUrl")]
pub error_image_url: Option<String>,
#[sea_orm(column_name = "iconUrl")]
pub icon_url: Option<String>,
#[sea_orm(column_name = "cacheRemoteFiles")]
pub cache_remote_files: bool,
#[sea_orm(column_name = "enableRecaptcha")]
pub enable_recaptcha: bool,
#[sea_orm(column_name = "recaptchaSiteKey")]
pub recaptcha_site_key: Option<String>,
#[sea_orm(column_name = "recaptchaSecretKey")]
pub recaptcha_secret_key: Option<String>,
#[sea_orm(column_name = "localDriveCapacityMb")]
pub local_drive_capacity_mb: i32,
#[sea_orm(column_name = "remoteDriveCapacityMb")]
pub remote_drive_capacity_mb: i32,
#[sea_orm(column_name = "summalyProxy")]
pub summaly_proxy: Option<String>,
#[sea_orm(column_name = "enableEmail")]
pub enable_email: bool,
pub email: Option<String>,
#[sea_orm(column_name = "smtpSecure")]
pub smtp_secure: bool,
#[sea_orm(column_name = "smtpHost")]
pub smtp_host: Option<String>,
#[sea_orm(column_name = "smtpPort")]
pub smtp_port: Option<i32>,
#[sea_orm(column_name = "smtpUser")]
pub smtp_user: Option<String>,
#[sea_orm(column_name = "smtpPass")]
pub smtp_pass: Option<String>,
#[sea_orm(column_name = "enableServiceWorker")]
pub enable_service_worker: bool,
#[sea_orm(column_name = "swPublicKey")]
pub sw_public_key: Option<String>,
#[sea_orm(column_name = "swPrivateKey")]
pub sw_private_key: Option<String>,
#[sea_orm(column_name = "enableTwitterIntegration")]
pub enable_twitter_integration: bool,
#[sea_orm(column_name = "twitterConsumerKey")]
pub twitter_consumer_key: Option<String>,
#[sea_orm(column_name = "twitterConsumerSecret")]
pub twitter_consumer_secret: Option<String>,
#[sea_orm(column_name = "enableGithubIntegration")]
pub enable_github_integration: bool,
#[sea_orm(column_name = "githubClientId")]
pub github_client_id: Option<String>,
#[sea_orm(column_name = "githubClientSecret")]
pub github_client_secret: Option<String>,
#[sea_orm(column_name = "enableDiscordIntegration")]
pub enable_discord_integration: bool,
#[sea_orm(column_name = "discordClientId")]
pub discord_client_id: Option<String>,
#[sea_orm(column_name = "discordClientSecret")]
pub discord_client_secret: Option<String>,
#[sea_orm(column_name = "pinnedUsers")]
pub pinned_users: Vec<String>,
#[sea_orm(column_name = "ToSUrl")]
pub to_s_url: Option<String>,
#[sea_orm(column_name = "repositoryUrl")]
pub repository_url: String,
#[sea_orm(column_name = "feedbackUrl")]
pub feedback_url: Option<String>,
#[sea_orm(column_name = "useObjectStorage")]
pub use_object_storage: bool,
#[sea_orm(column_name = "objectStorageBucket")]
pub object_storage_bucket: Option<String>,
#[sea_orm(column_name = "objectStoragePrefix")]
pub object_storage_prefix: Option<String>,
#[sea_orm(column_name = "objectStorageBaseUrl")]
pub object_storage_base_url: Option<String>,
#[sea_orm(column_name = "objectStorageEndpoint")]
pub object_storage_endpoint: Option<String>,
#[sea_orm(column_name = "objectStorageRegion")]
pub object_storage_region: Option<String>,
#[sea_orm(column_name = "objectStorageAccessKey")]
pub object_storage_access_key: Option<String>,
#[sea_orm(column_name = "objectStorageSecretKey")]
pub object_storage_secret_key: Option<String>,
#[sea_orm(column_name = "objectStoragePort")]
pub object_storage_port: Option<i32>,
#[sea_orm(column_name = "objectStorageUseSSL")]
pub object_storage_use_ssl: bool,
#[sea_orm(column_name = "proxyAccountId")]
pub proxy_account_id: Option<String>,
#[sea_orm(column_name = "objectStorageUseProxy")]
pub object_storage_use_proxy: bool,
#[sea_orm(column_name = "enableHcaptcha")]
pub enable_hcaptcha: bool,
#[sea_orm(column_name = "hcaptchaSiteKey")]
pub hcaptcha_site_key: Option<String>,
#[sea_orm(column_name = "hcaptchaSecretKey")]
pub hcaptcha_secret_key: Option<String>,
#[sea_orm(column_name = "objectStorageSetPublicRead")]
pub object_storage_set_public_read: bool,
#[sea_orm(column_name = "pinnedPages")]
pub pinned_pages: Vec<String>,
#[sea_orm(column_name = "backgroundImageUrl")]
pub background_image_url: Option<String>,
#[sea_orm(column_name = "logoImageUrl")]
pub logo_image_url: Option<String>,
#[sea_orm(column_name = "pinnedClipId")]
pub pinned_clip_id: Option<String>,
#[sea_orm(column_name = "objectStorageS3ForcePathStyle")]
pub object_storage_s3_force_path_style: bool,
#[sea_orm(column_name = "allowedHosts")]
pub allowed_hosts: Option<Vec<String>>,
#[sea_orm(column_name = "secureMode")]
pub secure_mode: Option<bool>,
#[sea_orm(column_name = "privateMode")]
pub private_mode: Option<bool>,
#[sea_orm(column_name = "deeplAuthKey")]
pub deepl_auth_key: Option<String>,
#[sea_orm(column_name = "deeplIsPro")]
pub deepl_is_pro: bool,
#[sea_orm(column_name = "emailRequiredForSignup")]
pub email_required_for_signup: bool,
#[sea_orm(column_name = "themeColor")]
pub theme_color: Option<String>,
#[sea_orm(column_name = "defaultLightTheme")]
pub default_light_theme: Option<String>,
#[sea_orm(column_name = "defaultDarkTheme")]
pub default_dark_theme: Option<String>,
#[sea_orm(column_name = "sensitiveMediaDetection")]
pub sensitive_media_detection: MetaSensitivemediadetectionEnum,
#[sea_orm(column_name = "sensitiveMediaDetectionSensitivity")]
pub sensitive_media_detection_sensitivity: MetaSensitivemediadetectionsensitivityEnum,
#[sea_orm(column_name = "setSensitiveFlagAutomatically")]
pub set_sensitive_flag_automatically: bool,
#[sea_orm(column_name = "enableIpLogging")]
pub enable_ip_logging: bool,
#[sea_orm(column_name = "enableSensitiveMediaDetectionForVideos")]
pub enable_sensitive_media_detection_for_videos: bool,
#[sea_orm(column_name = "enableActiveEmailValidation")]
pub enable_active_email_validation: bool,
#[sea_orm(column_name = "customMOTD")]
pub custom_motd: Vec<String>,
#[sea_orm(column_name = "customSplashIcons")]
pub custom_splash_icons: Vec<String>,
#[sea_orm(column_name = "disableRecommendedTimeline")]
pub disable_recommended_timeline: bool,
#[sea_orm(column_name = "recommendedInstances")]
pub recommended_instances: Vec<String>,
#[sea_orm(column_name = "enableGuestTimeline")]
pub enable_guest_timeline: bool,
#[sea_orm(column_name = "defaultReaction")]
pub default_reaction: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::ProxyAccountId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,17 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "migrations")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub timestamp: i64,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,74 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
pub mod prelude;
pub mod abuse_user_report;
pub mod access_token;
pub mod ad;
pub mod announcement;
pub mod announcement_read;
pub mod antenna;
pub mod antenna_note;
pub mod app;
pub mod attestation_challenge;
pub mod auth_session;
pub mod blocking;
pub mod channel;
pub mod channel_following;
pub mod channel_note_pining;
pub mod clip;
pub mod clip_note;
pub mod drive_file;
pub mod drive_folder;
pub mod emoji;
pub mod follow_request;
pub mod following;
pub mod gallery_like;
pub mod gallery_post;
pub mod hashtag;
pub mod instance;
pub mod messaging_message;
pub mod meta;
pub mod migrations;
pub mod moderation_log;
pub mod muted_note;
pub mod muting;
pub mod note;
pub mod note_favorite;
pub mod note_reaction;
pub mod note_thread_muting;
pub mod note_unread;
pub mod note_watching;
pub mod notification;
pub mod page;
pub mod page_like;
pub mod password_reset_request;
pub mod poll;
pub mod poll_vote;
pub mod promo_note;
pub mod promo_read;
pub mod registration_ticket;
pub mod registry_item;
pub mod relay;
pub mod renote_muting;
pub mod reversi_game;
pub mod reversi_matching;
pub mod sea_orm_active_enums;
pub mod signin;
pub mod sw_subscription;
pub mod used_username;
pub mod user;
pub mod user_group;
pub mod user_group_invitation;
pub mod user_group_invite;
pub mod user_group_joining;
pub mod user_ip;
pub mod user_keypair;
pub mod user_list;
pub mod user_list_joining;
pub mod user_note_pining;
pub mod user_pending;
pub mod user_profile;
pub mod user_publickey;
pub mod user_security_key;
pub mod webhook;

View File

@ -0,0 +1,36 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "moderation_log")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub r#type: String,
pub info: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::MutedNoteReasonEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muted_note")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub reason: MutedNoteReasonEnum,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,40 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muting")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "muteeId")]
pub mutee_id: String,
#[sea_orm(column_name = "muterId")]
pub muter_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::MuterId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::MuteeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,223 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::NoteVisibilityEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "replyId")]
pub reply_id: Option<String>,
#[sea_orm(column_name = "renoteId")]
pub renote_id: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub text: Option<String>,
pub name: Option<String>,
pub cw: Option<String>,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "localOnly")]
pub local_only: bool,
#[sea_orm(column_name = "renoteCount")]
pub renote_count: i16,
#[sea_orm(column_name = "repliesCount")]
pub replies_count: i16,
pub reactions: Json,
pub visibility: NoteVisibilityEnum,
pub uri: Option<String>,
pub score: i32,
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
#[sea_orm(column_name = "attachedFileTypes")]
pub attached_file_types: Vec<String>,
#[sea_orm(column_name = "visibleUserIds")]
pub visible_user_ids: Vec<String>,
pub mentions: Vec<String>,
#[sea_orm(column_name = "mentionedRemoteUsers", column_type = "Text")]
pub mentioned_remote_users: String,
pub emojis: Vec<String>,
pub tags: Vec<String>,
#[sea_orm(column_name = "hasPoll")]
pub has_poll: bool,
#[sea_orm(column_name = "userHost")]
pub user_host: Option<String>,
#[sea_orm(column_name = "replyUserId")]
pub reply_user_id: Option<String>,
#[sea_orm(column_name = "replyUserHost")]
pub reply_user_host: Option<String>,
#[sea_orm(column_name = "renoteUserId")]
pub renote_user_id: Option<String>,
#[sea_orm(column_name = "renoteUserHost")]
pub renote_user_host: Option<String>,
pub url: Option<String>,
#[sea_orm(column_name = "channelId")]
pub channel_id: Option<String>,
#[sea_orm(column_name = "threadId")]
pub thread_id: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::antenna_note::Entity")]
AntennaNote,
#[sea_orm(
belongs_to = "super::channel::Entity",
from = "Column::ChannelId",
to = "super::channel::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Channel,
#[sea_orm(has_many = "super::channel_note_pining::Entity")]
ChannelNotePining,
#[sea_orm(has_many = "super::clip_note::Entity")]
ClipNote,
#[sea_orm(has_many = "super::muted_note::Entity")]
MutedNote,
#[sea_orm(
belongs_to = "Entity",
from = "Column::ReplyId",
to = "Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SelfRef2,
#[sea_orm(
belongs_to = "Entity",
from = "Column::RenoteId",
to = "Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SelfRef1,
#[sea_orm(has_many = "super::note_favorite::Entity")]
NoteFavorite,
#[sea_orm(has_many = "super::note_reaction::Entity")]
NoteReaction,
#[sea_orm(has_many = "super::note_unread::Entity")]
NoteUnread,
#[sea_orm(has_many = "super::note_watching::Entity")]
NoteWatching,
#[sea_orm(has_many = "super::notification::Entity")]
Notification,
#[sea_orm(has_one = "super::poll::Entity")]
Poll,
#[sea_orm(has_many = "super::poll_vote::Entity")]
PollVote,
#[sea_orm(has_one = "super::promo_note::Entity")]
PromoNote,
#[sea_orm(has_many = "super::promo_read::Entity")]
PromoRead,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(has_many = "super::user_note_pining::Entity")]
UserNotePining,
}
impl Related<super::antenna_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::AntennaNote.def()
}
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::channel_note_pining::Entity> for Entity {
fn to() -> RelationDef {
Relation::ChannelNotePining.def()
}
}
impl Related<super::clip_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::ClipNote.def()
}
}
impl Related<super::muted_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::MutedNote.def()
}
}
impl Related<super::note_favorite::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteFavorite.def()
}
}
impl Related<super::note_reaction::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteReaction.def()
}
}
impl Related<super::note_unread::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteUnread.def()
}
}
impl Related<super::note_watching::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteWatching.def()
}
}
impl Related<super::notification::Entity> for Entity {
fn to() -> RelationDef {
Relation::Notification.def()
}
}
impl Related<super::poll::Entity> for Entity {
fn to() -> RelationDef {
Relation::Poll.def()
}
}
impl Related<super::poll_vote::Entity> for Entity {
fn to() -> RelationDef {
Relation::PollVote.def()
}
}
impl Related<super::promo_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::PromoNote.def()
}
}
impl Related<super::promo_read::Entity> for Entity {
fn to() -> RelationDef {
Relation::PromoRead.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_note_pining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserNotePining.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_favorite")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,51 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_reaction")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
pub reaction: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,36 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_thread_muting")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "threadId")]
pub thread_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,56 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_unread")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
#[sea_orm(column_name = "noteUserId")]
pub note_user_id: String,
#[sea_orm(column_name = "isSpecified")]
pub is_specified: bool,
#[sea_orm(column_name = "isMentioned")]
pub is_mentioned: bool,
#[sea_orm(column_name = "noteChannelId")]
pub note_channel_id: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,52 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_watching")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
#[sea_orm(column_name = "noteUserId")]
pub note_user_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,114 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::NotificationTypeEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "notification")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "notifieeId")]
pub notifiee_id: String,
#[sea_orm(column_name = "notifierId")]
pub notifier_id: Option<String>,
#[sea_orm(column_name = "isRead")]
pub is_read: bool,
#[sea_orm(column_name = "noteId")]
pub note_id: Option<String>,
pub reaction: Option<String>,
pub choice: Option<i32>,
#[sea_orm(column_name = "followRequestId")]
pub follow_request_id: Option<String>,
pub r#type: NotificationTypeEnum,
#[sea_orm(column_name = "userGroupInvitationId")]
pub user_group_invitation_id: Option<String>,
#[sea_orm(column_name = "customBody")]
pub custom_body: Option<String>,
#[sea_orm(column_name = "customHeader")]
pub custom_header: Option<String>,
#[sea_orm(column_name = "customIcon")]
pub custom_icon: Option<String>,
#[sea_orm(column_name = "appAccessTokenId")]
pub app_access_token_id: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::access_token::Entity",
from = "Column::AppAccessTokenId",
to = "super::access_token::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
AccessToken,
#[sea_orm(
belongs_to = "super::follow_request::Entity",
from = "Column::FollowRequestId",
to = "super::follow_request::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
FollowRequest,
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::NotifierId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::NotifieeId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
#[sea_orm(
belongs_to = "super::user_group_invitation::Entity",
from = "Column::UserGroupInvitationId",
to = "super::user_group_invitation::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroupInvitation,
}
impl Related<super::access_token::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessToken.def()
}
}
impl Related<super::follow_request::Entity> for Entity {
fn to() -> RelationDef {
Relation::FollowRequest.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user_group_invitation::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupInvitation.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,87 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::PageVisibilityEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub title: String,
pub name: String,
pub summary: Option<String>,
#[sea_orm(column_name = "alignCenter")]
pub align_center: bool,
pub font: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "eyeCatchingImageId")]
pub eye_catching_image_id: Option<String>,
pub content: Json,
pub variables: Json,
pub visibility: PageVisibilityEnum,
#[sea_orm(column_name = "visibleUserIds")]
pub visible_user_ids: Vec<String>,
#[sea_orm(column_name = "likedCount")]
pub liked_count: i32,
#[sea_orm(column_name = "hideTitleWhenPinned")]
pub hide_title_when_pinned: bool,
pub script: String,
#[sea_orm(column_name = "isPublic")]
pub is_public: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::drive_file::Entity",
from = "Column::EyeCatchingImageId",
to = "super::drive_file::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
DriveFile,
#[sea_orm(has_many = "super::page_like::Entity")]
PageLike,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(has_one = "super::user_profile::Entity")]
UserProfile,
}
impl Related<super::drive_file::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFile.def()
}
}
impl Related<super::page_like::Entity> for Entity {
fn to() -> RelationDef {
Relation::PageLike.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_profile::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserProfile.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page_like")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "pageId")]
pub page_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::page::Entity",
from = "Column::PageId",
to = "super::page::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Page,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,35 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "password_reset_request")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub token: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,42 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::PollNotevisibilityEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll")]
pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: Option<DateTimeWithTimeZone>,
pub multiple: bool,
pub choices: Vec<String>,
pub votes: Vec<i32>,
#[sea_orm(column_name = "noteVisibility")]
pub note_visibility: PollNotevisibilityEnum,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userHost")]
pub user_host: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,51 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll_vote")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
pub choice: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,71 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
pub use super::abuse_user_report::Entity as AbuseUserReport;
pub use super::access_token::Entity as AccessToken;
pub use super::ad::Entity as Ad;
pub use super::announcement::Entity as Announcement;
pub use super::announcement_read::Entity as AnnouncementRead;
pub use super::antenna::Entity as Antenna;
pub use super::antenna_note::Entity as AntennaNote;
pub use super::app::Entity as App;
pub use super::attestation_challenge::Entity as AttestationChallenge;
pub use super::auth_session::Entity as AuthSession;
pub use super::blocking::Entity as Blocking;
pub use super::channel::Entity as Channel;
pub use super::channel_following::Entity as ChannelFollowing;
pub use super::channel_note_pining::Entity as ChannelNotePining;
pub use super::clip::Entity as Clip;
pub use super::clip_note::Entity as ClipNote;
pub use super::drive_file::Entity as DriveFile;
pub use super::drive_folder::Entity as DriveFolder;
pub use super::emoji::Entity as Emoji;
pub use super::follow_request::Entity as FollowRequest;
pub use super::following::Entity as Following;
pub use super::gallery_like::Entity as GalleryLike;
pub use super::gallery_post::Entity as GalleryPost;
pub use super::hashtag::Entity as Hashtag;
pub use super::instance::Entity as Instance;
pub use super::messaging_message::Entity as MessagingMessage;
pub use super::meta::Entity as Meta;
pub use super::migrations::Entity as Migrations;
pub use super::moderation_log::Entity as ModerationLog;
pub use super::muted_note::Entity as MutedNote;
pub use super::muting::Entity as Muting;
pub use super::note::Entity as Note;
pub use super::note_favorite::Entity as NoteFavorite;
pub use super::note_reaction::Entity as NoteReaction;
pub use super::note_thread_muting::Entity as NoteThreadMuting;
pub use super::note_unread::Entity as NoteUnread;
pub use super::note_watching::Entity as NoteWatching;
pub use super::notification::Entity as Notification;
pub use super::page::Entity as Page;
pub use super::page_like::Entity as PageLike;
pub use super::password_reset_request::Entity as PasswordResetRequest;
pub use super::poll::Entity as Poll;
pub use super::poll_vote::Entity as PollVote;
pub use super::promo_note::Entity as PromoNote;
pub use super::promo_read::Entity as PromoRead;
pub use super::registration_ticket::Entity as RegistrationTicket;
pub use super::registry_item::Entity as RegistryItem;
pub use super::relay::Entity as Relay;
pub use super::renote_muting::Entity as RenoteMuting;
pub use super::reversi_game::Entity as ReversiGame;
pub use super::reversi_matching::Entity as ReversiMatching;
pub use super::signin::Entity as Signin;
pub use super::sw_subscription::Entity as SwSubscription;
pub use super::used_username::Entity as UsedUsername;
pub use super::user::Entity as User;
pub use super::user_group::Entity as UserGroup;
pub use super::user_group_invitation::Entity as UserGroupInvitation;
pub use super::user_group_invite::Entity as UserGroupInvite;
pub use super::user_group_joining::Entity as UserGroupJoining;
pub use super::user_ip::Entity as UserIp;
pub use super::user_keypair::Entity as UserKeypair;
pub use super::user_list::Entity as UserList;
pub use super::user_list_joining::Entity as UserListJoining;
pub use super::user_note_pining::Entity as UserNotePining;
pub use super::user_pending::Entity as UserPending;
pub use super::user_profile::Entity as UserProfile;
pub use super::user_publickey::Entity as UserPublickey;
pub use super::user_security_key::Entity as UserSecurityKey;
pub use super::webhook::Entity as Webhook;

View File

@ -0,0 +1,34 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_note")]
pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_read")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,18 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registration_ticket")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub code: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,40 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registry_item")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub key: String,
pub scope: Vec<String>,
pub domain: Option<String>,
pub value: Option<Json>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,18 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::RelayStatusEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "relay")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub inbox: String,
pub status: RelayStatusEnum,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,21 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "renote_muting")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "muteeId")]
pub mutee_id: String,
#[sea_orm(column_name = "muterId")]
pub muter_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,64 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "reversi_game")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "startedAt")]
pub started_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "user1Id")]
pub user1_id: String,
#[sea_orm(column_name = "user2Id")]
pub user2_id: String,
#[sea_orm(column_name = "user1Accepted")]
pub user1_accepted: bool,
#[sea_orm(column_name = "user2Accepted")]
pub user2_accepted: bool,
pub black: Option<i32>,
#[sea_orm(column_name = "isStarted")]
pub is_started: bool,
#[sea_orm(column_name = "isEnded")]
pub is_ended: bool,
#[sea_orm(column_name = "winnerId")]
pub winner_id: Option<String>,
pub surrendered: Option<String>,
pub logs: Json,
pub map: Vec<String>,
pub bw: String,
#[sea_orm(column_name = "isLlotheo")]
pub is_llotheo: bool,
#[sea_orm(column_name = "canPutEverywhere")]
pub can_put_everywhere: bool,
#[sea_orm(column_name = "loopedBoard")]
pub looped_board: bool,
pub form1: Option<Json>,
pub form2: Option<Json>,
pub crc32: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::User2Id",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::User1Id",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,38 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "reversi_matching")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "parentId")]
pub parent_id: String,
#[sea_orm(column_name = "childId")]
pub child_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::ParentId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User2,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::ChildId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,172 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")]
pub enum AntennaSrcEnum {
#[sea_orm(string_value = "all")]
All,
#[sea_orm(string_value = "group")]
Group,
#[sea_orm(string_value = "home")]
Home,
#[sea_orm(string_value = "instances")]
Instances,
#[sea_orm(string_value = "list")]
List,
#[sea_orm(string_value = "users")]
Users,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "meta_sensitivemediadetection_enum"
)]
pub enum MetaSensitivemediadetectionEnum {
#[sea_orm(string_value = "all")]
All,
#[sea_orm(string_value = "local")]
Local,
#[sea_orm(string_value = "none")]
None,
#[sea_orm(string_value = "remote")]
Remote,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "meta_sensitivemediadetectionsensitivity_enum"
)]
pub enum MetaSensitivemediadetectionsensitivityEnum {
#[sea_orm(string_value = "high")]
High,
#[sea_orm(string_value = "low")]
Low,
#[sea_orm(string_value = "medium")]
Medium,
#[sea_orm(string_value = "veryHigh")]
VeryHigh,
#[sea_orm(string_value = "veryLow")]
VeryLow,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "muted_note_reason_enum"
)]
pub enum MutedNoteReasonEnum {
#[sea_orm(string_value = "manual")]
Manual,
#[sea_orm(string_value = "other")]
Other,
#[sea_orm(string_value = "spam")]
Spam,
#[sea_orm(string_value = "word")]
Word,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "note_visibility_enum"
)]
pub enum NoteVisibilityEnum {
#[sea_orm(string_value = "followers")]
Followers,
#[sea_orm(string_value = "home")]
Home,
#[sea_orm(string_value = "public")]
Public,
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "notification_type_enum"
)]
pub enum NotificationTypeEnum {
#[sea_orm(string_value = "app")]
App,
#[sea_orm(string_value = "follow")]
Follow,
#[sea_orm(string_value = "followRequestAccepted")]
FollowRequestAccepted,
#[sea_orm(string_value = "groupInvited")]
GroupInvited,
#[sea_orm(string_value = "mention")]
Mention,
#[sea_orm(string_value = "pollEnded")]
PollEnded,
#[sea_orm(string_value = "pollVote")]
PollVote,
#[sea_orm(string_value = "quote")]
Quote,
#[sea_orm(string_value = "reaction")]
Reaction,
#[sea_orm(string_value = "receiveFollowRequest")]
ReceiveFollowRequest,
#[sea_orm(string_value = "renote")]
Renote,
#[sea_orm(string_value = "reply")]
Reply,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "page_visibility_enum"
)]
pub enum PageVisibilityEnum {
#[sea_orm(string_value = "followers")]
Followers,
#[sea_orm(string_value = "public")]
Public,
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "poll_notevisibility_enum"
)]
pub enum PollNotevisibilityEnum {
#[sea_orm(string_value = "followers")]
Followers,
#[sea_orm(string_value = "home")]
Home,
#[sea_orm(string_value = "public")]
Public,
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")]
pub enum RelayStatusEnum {
#[sea_orm(string_value = "accepted")]
Accepted,
#[sea_orm(string_value = "rejected")]
Rejected,
#[sea_orm(string_value = "requesting")]
Requesting,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "user_profile_ffvisibility_enum"
)]
pub enum UserProfileFfvisibilityEnum {
#[sea_orm(string_value = "followers")]
Followers,
#[sea_orm(string_value = "private")]
Private,
#[sea_orm(string_value = "public")]
Public,
}

View File

@ -0,0 +1,37 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "signin")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub ip: String,
pub headers: Json,
pub success: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,39 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "sw_subscription")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub endpoint: String,
pub auth: String,
pub publickey: String,
#[sea_orm(column_name = "sendReadMessage")]
pub send_read_message: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,17 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "used_username")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub username: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,424 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "lastFetchedAt")]
pub last_fetched_at: Option<DateTimeWithTimeZone>,
pub username: String,
#[sea_orm(column_name = "usernameLower")]
pub username_lower: String,
pub name: Option<String>,
#[sea_orm(column_name = "followersCount")]
pub followers_count: i32,
#[sea_orm(column_name = "followingCount")]
pub following_count: i32,
#[sea_orm(column_name = "notesCount")]
pub notes_count: i32,
#[sea_orm(column_name = "avatarId", unique)]
pub avatar_id: Option<String>,
#[sea_orm(column_name = "bannerId", unique)]
pub banner_id: Option<String>,
pub tags: Vec<String>,
#[sea_orm(column_name = "isSuspended")]
pub is_suspended: bool,
#[sea_orm(column_name = "isSilenced")]
pub is_silenced: bool,
#[sea_orm(column_name = "isLocked")]
pub is_locked: bool,
#[sea_orm(column_name = "isBot")]
pub is_bot: bool,
#[sea_orm(column_name = "isCat")]
pub is_cat: bool,
#[sea_orm(column_name = "isAdmin")]
pub is_admin: bool,
#[sea_orm(column_name = "isModerator")]
pub is_moderator: bool,
pub emojis: Vec<String>,
pub host: Option<String>,
pub inbox: Option<String>,
#[sea_orm(column_name = "sharedInbox")]
pub shared_inbox: Option<String>,
pub featured: Option<String>,
pub uri: Option<String>,
#[sea_orm(unique)]
pub token: Option<String>,
#[sea_orm(column_name = "isExplorable")]
pub is_explorable: bool,
#[sea_orm(column_name = "followersUri")]
pub followers_uri: Option<String>,
#[sea_orm(column_name = "lastActiveDate")]
pub last_active_date: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "hideOnlineStatus")]
pub hide_online_status: bool,
#[sea_orm(column_name = "isDeleted")]
pub is_deleted: bool,
#[sea_orm(column_name = "showTimelineReplies")]
pub show_timeline_replies: bool,
#[sea_orm(column_name = "driveCapacityOverrideMb")]
pub drive_capacity_override_mb: Option<i32>,
#[sea_orm(column_name = "movedToUri")]
pub moved_to_uri: Option<String>,
#[sea_orm(column_name = "alsoKnownAs", column_type = "Text", nullable)]
pub also_known_as: Option<String>,
#[sea_orm(column_name = "speakAsCat")]
pub speak_as_cat: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::access_token::Entity")]
AccessToken,
#[sea_orm(has_many = "super::announcement_read::Entity")]
AnnouncementRead,
#[sea_orm(has_many = "super::antenna::Entity")]
Antenna,
#[sea_orm(has_many = "super::app::Entity")]
App,
#[sea_orm(has_many = "super::attestation_challenge::Entity")]
AttestationChallenge,
#[sea_orm(has_many = "super::auth_session::Entity")]
AuthSession,
#[sea_orm(has_many = "super::channel::Entity")]
Channel,
#[sea_orm(has_many = "super::channel_following::Entity")]
ChannelFollowing,
#[sea_orm(has_many = "super::clip::Entity")]
Clip,
#[sea_orm(
belongs_to = "super::drive_file::Entity",
from = "Column::AvatarId",
to = "super::drive_file::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
DriveFile2,
#[sea_orm(
belongs_to = "super::drive_file::Entity",
from = "Column::BannerId",
to = "super::drive_file::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
DriveFile1,
#[sea_orm(has_many = "super::drive_folder::Entity")]
DriveFolder,
#[sea_orm(has_many = "super::gallery_like::Entity")]
GalleryLike,
#[sea_orm(has_many = "super::gallery_post::Entity")]
GalleryPost,
#[sea_orm(has_many = "super::meta::Entity")]
Meta,
#[sea_orm(has_many = "super::moderation_log::Entity")]
ModerationLog,
#[sea_orm(has_many = "super::muted_note::Entity")]
MutedNote,
#[sea_orm(has_many = "super::note::Entity")]
Note,
#[sea_orm(has_many = "super::note_favorite::Entity")]
NoteFavorite,
#[sea_orm(has_many = "super::note_reaction::Entity")]
NoteReaction,
#[sea_orm(has_many = "super::note_thread_muting::Entity")]
NoteThreadMuting,
#[sea_orm(has_many = "super::note_unread::Entity")]
NoteUnread,
#[sea_orm(has_many = "super::note_watching::Entity")]
NoteWatching,
#[sea_orm(has_many = "super::page::Entity")]
Page,
#[sea_orm(has_many = "super::page_like::Entity")]
PageLike,
#[sea_orm(has_many = "super::password_reset_request::Entity")]
PasswordResetRequest,
#[sea_orm(has_many = "super::poll_vote::Entity")]
PollVote,
#[sea_orm(has_many = "super::promo_read::Entity")]
PromoRead,
#[sea_orm(has_many = "super::registry_item::Entity")]
RegistryItem,
#[sea_orm(has_many = "super::signin::Entity")]
Signin,
#[sea_orm(has_many = "super::sw_subscription::Entity")]
SwSubscription,
#[sea_orm(has_many = "super::user_group::Entity")]
UserGroup,
#[sea_orm(has_many = "super::user_group_invitation::Entity")]
UserGroupInvitation,
#[sea_orm(has_many = "super::user_group_invite::Entity")]
UserGroupInvite,
#[sea_orm(has_many = "super::user_group_joining::Entity")]
UserGroupJoining,
#[sea_orm(has_one = "super::user_keypair::Entity")]
UserKeypair,
#[sea_orm(has_many = "super::user_list::Entity")]
UserList,
#[sea_orm(has_many = "super::user_list_joining::Entity")]
UserListJoining,
#[sea_orm(has_many = "super::user_note_pining::Entity")]
UserNotePining,
#[sea_orm(has_one = "super::user_profile::Entity")]
UserProfile,
#[sea_orm(has_one = "super::user_publickey::Entity")]
UserPublickey,
#[sea_orm(has_many = "super::user_security_key::Entity")]
UserSecurityKey,
#[sea_orm(has_many = "super::webhook::Entity")]
Webhook,
}
impl Related<super::access_token::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessToken.def()
}
}
impl Related<super::announcement_read::Entity> for Entity {
fn to() -> RelationDef {
Relation::AnnouncementRead.def()
}
}
impl Related<super::antenna::Entity> for Entity {
fn to() -> RelationDef {
Relation::Antenna.def()
}
}
impl Related<super::app::Entity> for Entity {
fn to() -> RelationDef {
Relation::App.def()
}
}
impl Related<super::attestation_challenge::Entity> for Entity {
fn to() -> RelationDef {
Relation::AttestationChallenge.def()
}
}
impl Related<super::auth_session::Entity> for Entity {
fn to() -> RelationDef {
Relation::AuthSession.def()
}
}
impl Related<super::channel::Entity> for Entity {
fn to() -> RelationDef {
Relation::Channel.def()
}
}
impl Related<super::channel_following::Entity> for Entity {
fn to() -> RelationDef {
Relation::ChannelFollowing.def()
}
}
impl Related<super::clip::Entity> for Entity {
fn to() -> RelationDef {
Relation::Clip.def()
}
}
impl Related<super::drive_folder::Entity> for Entity {
fn to() -> RelationDef {
Relation::DriveFolder.def()
}
}
impl Related<super::gallery_like::Entity> for Entity {
fn to() -> RelationDef {
Relation::GalleryLike.def()
}
}
impl Related<super::gallery_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::GalleryPost.def()
}
}
impl Related<super::meta::Entity> for Entity {
fn to() -> RelationDef {
Relation::Meta.def()
}
}
impl Related<super::moderation_log::Entity> for Entity {
fn to() -> RelationDef {
Relation::ModerationLog.def()
}
}
impl Related<super::muted_note::Entity> for Entity {
fn to() -> RelationDef {
Relation::MutedNote.def()
}
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::note_favorite::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteFavorite.def()
}
}
impl Related<super::note_reaction::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteReaction.def()
}
}
impl Related<super::note_thread_muting::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteThreadMuting.def()
}
}
impl Related<super::note_unread::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteUnread.def()
}
}
impl Related<super::note_watching::Entity> for Entity {
fn to() -> RelationDef {
Relation::NoteWatching.def()
}
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::page_like::Entity> for Entity {
fn to() -> RelationDef {
Relation::PageLike.def()
}
}
impl Related<super::password_reset_request::Entity> for Entity {
fn to() -> RelationDef {
Relation::PasswordResetRequest.def()
}
}
impl Related<super::poll_vote::Entity> for Entity {
fn to() -> RelationDef {
Relation::PollVote.def()
}
}
impl Related<super::promo_read::Entity> for Entity {
fn to() -> RelationDef {
Relation::PromoRead.def()
}
}
impl Related<super::registry_item::Entity> for Entity {
fn to() -> RelationDef {
Relation::RegistryItem.def()
}
}
impl Related<super::signin::Entity> for Entity {
fn to() -> RelationDef {
Relation::Signin.def()
}
}
impl Related<super::sw_subscription::Entity> for Entity {
fn to() -> RelationDef {
Relation::SwSubscription.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl Related<super::user_group_invitation::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupInvitation.def()
}
}
impl Related<super::user_group_invite::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupInvite.def()
}
}
impl Related<super::user_group_joining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupJoining.def()
}
}
impl Related<super::user_keypair::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserKeypair.def()
}
}
impl Related<super::user_list::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserList.def()
}
}
impl Related<super::user_list_joining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserListJoining.def()
}
}
impl Related<super::user_note_pining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserNotePining.def()
}
}
impl Related<super::user_profile::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserProfile.def()
}
}
impl Related<super::user_publickey::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserPublickey.def()
}
}
impl Related<super::user_security_key::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserSecurityKey.def()
}
}
impl Related<super::webhook::Entity> for Entity {
fn to() -> RelationDef {
Relation::Webhook.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,69 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub name: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "isPrivate")]
pub is_private: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::messaging_message::Entity")]
MessagingMessage,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(has_many = "super::user_group_invitation::Entity")]
UserGroupInvitation,
#[sea_orm(has_many = "super::user_group_invite::Entity")]
UserGroupInvite,
#[sea_orm(has_many = "super::user_group_joining::Entity")]
UserGroupJoining,
}
impl Related<super::messaging_message::Entity> for Entity {
fn to() -> RelationDef {
Relation::MessagingMessage.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_group_invitation::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupInvitation.def()
}
}
impl Related<super::user_group_invite::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupInvite.def()
}
}
impl Related<super::user_group_joining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupJoining.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,58 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invitation")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]
pub user_group_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::notification::Entity")]
Notification,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(
belongs_to = "super::user_group::Entity",
from = "Column::UserGroupId",
to = "super::user_group::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroup,
}
impl Related<super::notification::Entity> for Entity {
fn to() -> RelationDef {
Relation::Notification.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invite")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]
pub user_group_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(
belongs_to = "super::user_group::Entity",
from = "Column::UserGroupId",
to = "super::user_group::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroup,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,58 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_joining")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]
pub user_group_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::antenna::Entity")]
Antenna,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(
belongs_to = "super::user_group::Entity",
from = "Column::UserGroupId",
to = "super::user_group::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserGroup,
}
impl Related<super::antenna::Entity> for Entity {
fn to() -> RelationDef {
Relation::Antenna.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,20 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_ip")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub ip: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,34 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_keypair")]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,
#[sea_orm(column_name = "publicKey")]
pub public_key: String,
#[sea_orm(column_name = "privateKey")]
pub private_key: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,51 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::antenna::Entity")]
Antenna,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(has_many = "super::user_list_joining::Entity")]
UserListJoining,
}
impl Related<super::antenna::Entity> for Entity {
fn to() -> RelationDef {
Relation::Antenna.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_list_joining::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserListJoining.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list_joining")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userListId")]
pub user_list_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
#[sea_orm(
belongs_to = "super::user_list::Entity",
from = "Column::UserListId",
to = "super::user_list::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
UserList,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl Related<super::user_list::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserList.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,50 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_note_pining")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]
pub note_id: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::note::Entity",
from = "Column::NoteId",
to = "super::note::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Note,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::note::Entity> for Entity {
fn to() -> RelationDef {
Relation::Note.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,21 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_pending")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub code: String,
pub username: String,
pub email: String,
pub password: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,105 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use super::sea_orm_active_enums::UserProfileFfvisibilityEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_profile")]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,
pub location: Option<String>,
pub birthday: Option<String>,
pub description: Option<String>,
pub fields: Json,
pub url: Option<String>,
pub email: Option<String>,
#[sea_orm(column_name = "emailVerifyCode")]
pub email_verify_code: Option<String>,
#[sea_orm(column_name = "emailVerified")]
pub email_verified: bool,
#[sea_orm(column_name = "twoFactorTempSecret")]
pub two_factor_temp_secret: Option<String>,
#[sea_orm(column_name = "twoFactorSecret")]
pub two_factor_secret: Option<String>,
#[sea_orm(column_name = "twoFactorEnabled")]
pub two_factor_enabled: bool,
pub password: Option<String>,
#[sea_orm(column_name = "clientData")]
pub client_data: Json,
#[sea_orm(column_name = "autoAcceptFollowed")]
pub auto_accept_followed: bool,
#[sea_orm(column_name = "alwaysMarkNsfw")]
pub always_mark_nsfw: bool,
#[sea_orm(column_name = "carefulBot")]
pub careful_bot: bool,
#[sea_orm(column_name = "userHost")]
pub user_host: Option<String>,
#[sea_orm(column_name = "securityKeysAvailable")]
pub security_keys_available: bool,
#[sea_orm(column_name = "usePasswordLessLogin")]
pub use_password_less_login: bool,
#[sea_orm(column_name = "pinnedPageId", unique)]
pub pinned_page_id: Option<String>,
pub room: Json,
pub integrations: Json,
#[sea_orm(column_name = "injectFeaturedNote")]
pub inject_featured_note: bool,
#[sea_orm(column_name = "enableWordMute")]
pub enable_word_mute: bool,
#[sea_orm(column_name = "mutedWords")]
pub muted_words: Json,
#[sea_orm(column_name = "mutingNotificationTypes")]
pub muting_notification_types: Vec<String>,
#[sea_orm(column_name = "noCrawle")]
pub no_crawle: bool,
#[sea_orm(column_name = "receiveAnnouncementEmail")]
pub receive_announcement_email: bool,
#[sea_orm(column_name = "emailNotificationTypes")]
pub email_notification_types: Json,
pub lang: Option<String>,
#[sea_orm(column_name = "mutedInstances")]
pub muted_instances: Json,
#[sea_orm(column_name = "publicReactions")]
pub public_reactions: bool,
#[sea_orm(column_name = "ffVisibility")]
pub ff_visibility: UserProfileFfvisibilityEnum,
#[sea_orm(column_name = "autoSensitive")]
pub auto_sensitive: bool,
#[sea_orm(column_name = "moderationNote")]
pub moderation_note: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::page::Entity",
from = "Column::PinnedPageId",
to = "super::page::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
Page,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,34 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_publickey")]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,
#[sea_orm(column_name = "keyId")]
pub key_id: String,
#[sea_orm(column_name = "keyPem")]
pub key_pem: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,37 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_security_key")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "publicKey")]
pub public_key: String,
#[sea_orm(column_name = "lastUsed")]
pub last_used: DateTimeWithTimeZone,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,43 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "webhook")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
pub on: Vec<String>,
pub url: String,
pub secret: String,
pub active: bool,
#[sea_orm(column_name = "latestSentAt")]
pub latest_sent_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_name = "latestStatus")]
pub latest_status: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -0,0 +1,3 @@
pub use entities::*;
mod entities;

View File

@ -0,0 +1,56 @@
use ck::user;
use log::LevelFilter;
use sea_orm::{ColumnTrait, ConnectOptions, DatabaseConnection, EntityTrait, QueryFilter};
#[derive(Debug)]
pub struct ConnectorConfig {
pub url: String,
}
#[derive(Clone, Debug)]
pub struct CalckeyModel(DatabaseConnection);
impl CalckeyModel {
pub async fn new(config: ConnectorConfig) -> anyhow::Result<Self> {
let opt = ConnectOptions::new(config.url)
.max_connections(64)
.min_connections(8)
.sqlx_logging(true)
.sqlx_logging_level(LevelFilter::Debug)
.to_owned();
Ok(CalckeyModel(sea_orm::Database::connect(opt).await?))
}
pub async fn get_user_by_tag(
&self,
name: &str,
instance: Option<&str>,
) -> anyhow::Result<Option<user::Model>> {
let name = name.to_lowercase();
let instance = instance.map(str::to_lowercase);
let user = if let Some(instance) = instance {
user::Entity::find()
.filter(user::Column::UsernameLower.eq(name))
.filter(user::Column::Host.eq(instance))
} else {
user::Entity::find().filter(
user::Column::UsernameLower
.eq(name)
.and(user::Column::Host.is_null()),
)
}
.one(&self.0)
.await?;
Ok(user)
}
pub async fn get_user_by_uri(&self, uri: &str) -> anyhow::Result<Option<user::Model>> {
Ok(user::Entity::find()
.filter(user::Column::Uri.eq(uri))
.one(&self.0)
.await?)
}
}

8
ext_nodeinfo/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "magnetar_nodeinfo"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

169
ext_nodeinfo/src/lib.rs Normal file
View File

@ -0,0 +1,169 @@
use crate::version_1_0::NodeInfo10;
use crate::version_1_1::NodeInfo11;
use crate::version_2_0::NodeInfo20;
use crate::version_2_1::NodeInfo21;
use serde::{Deserialize, Serialize};
pub mod version_1_0;
pub mod version_1_1;
pub mod version_2_0;
pub mod version_2_1;
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(tag = "version")]
pub enum NodeInfo {
#[serde(rename = "1.0")]
V1_0(NodeInfo10),
#[serde(rename = "1.1")]
V1_1(NodeInfo11),
#[serde(rename = "2.0")]
V2_0(NodeInfo20),
#[serde(rename = "2.1")]
V2_1(NodeInfo21),
}
#[cfg(test)]
mod test {
use crate::version_1_0::{
NodeInfo10Services, NodeInfo10Software, NodeInfo10Usage, NodeInfo10UsageUsers,
};
use crate::version_2_0::NodeInfo20;
use crate::version_2_1::{NodeInfo21, NodeInfo21Software};
use crate::NodeInfo;
use serde_json::json;
use std::collections::{HashMap, HashSet};
fn json_mastodon() -> serde_json::Value {
json!({
"version": "2.0",
"software": {
"name": "mastodon",
"version": "4.1.0"
},
"protocols": [
"activitypub"
],
"services": {
"outbound": [],
"inbound": []
},
"usage": {
"users": {
"total": 10360,
"activeMonth": 4627,
"activeHalfyear": 10089
},
"localPosts": 1033206
},
"openRegistrations": true,
"metadata": {}
})
}
fn data_mastodon() -> NodeInfo20 {
NodeInfo20 {
software: NodeInfo10Software {
name: "mastodon".to_owned(),
version: "4.1.0".to_owned(),
},
protocols: HashSet::from(["activitypub".to_owned()]),
services: NodeInfo10Services {
inbound: HashSet::new(),
outbound: HashSet::new(),
},
open_registrations: true,
usage: NodeInfo10Usage {
users: NodeInfo10UsageUsers {
total: Some(10360),
active_halfyear: Some(10089),
active_month: Some(4627),
},
local_posts: Some(1033206),
local_comments: None,
},
metadata: HashMap::new(),
}
}
#[test]
fn should_serialize_nodeinfo_20() {
let json = json_mastodon();
let node_info = serde_json::to_value(NodeInfo::V2_0(data_mastodon())).unwrap();
assert_eq!(node_info, json);
}
#[test]
fn should_parse_nodeinfo_20() {
let json = json_mastodon();
let node_info: NodeInfo = serde_json::from_value(json).unwrap();
assert_eq!(node_info, NodeInfo::V2_0(data_mastodon()));
}
#[test]
fn should_parse_nodeinfo_21() {
let json = json!({
"version": "2.1",
"software": {
"name": "calckey",
"version": "13.1.2",
"repository": "https://github.com/misskey-dev/misskey",
"homepage": "https://calckey.cloud"
},
"protocols": [
"activitypub"
],
"services": {
"inbound": [],
"outbound": [
"atom1.0",
"rss2.0"
]
},
"openRegistrations": false,
"usage": {
"users": {
"total": 2,
"activeHalfyear": 1,
"activeMonth": 1
},
"localPosts": 1936,
"localComments": 0
},
"metadata": {}
});
let node_info: NodeInfo = serde_json::from_value(json).unwrap();
assert_eq!(
node_info,
NodeInfo::V2_1(NodeInfo21 {
software: NodeInfo21Software {
name: "calckey".to_owned(),
version: "13.1.2".to_owned(),
homepage: Some("https://calckey.cloud".to_owned()),
repository: Some("https://github.com/misskey-dev/misskey".to_owned())
},
protocols: HashSet::from(["activitypub".to_owned()]),
services: NodeInfo10Services {
inbound: HashSet::new(),
outbound: HashSet::from(["atom1.0".to_owned(), "rss2.0".to_owned()])
},
open_registrations: false,
usage: NodeInfo10Usage {
users: NodeInfo10UsageUsers {
total: Some(2),
active_halfyear: Some(1),
active_month: Some(1)
},
local_posts: Some(1936),
local_comments: Some(0)
},
metadata: HashMap::new()
})
);
}
}

View File

@ -0,0 +1,76 @@
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo10Protocols {
#[doc = "The protocols this server can receive traffic for."]
pub inbound: HashSet<String>,
#[doc = "The protocols this server can generate traffic for."]
pub outbound: HashSet<String>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo10Services {
#[doc = "The third party sites this server can retrieve messages from for combined display with "]
#[doc = "regular traffic."]
pub inbound: HashSet<String>,
#[doc = "The third party sites this server can publish messages to on the behalf of a user."]
pub outbound: HashSet<String>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo10Software {
#[doc = "The canonical name of this server software."]
pub name: String,
#[doc = "The version of this server software."]
pub version: String,
}
#[derive(Clone, PartialEq, Debug, Default, Deserialize, Serialize)]
pub struct NodeInfo10UsageUsers {
#[doc = "The amount of users that signed in at least once in the last 180 days."]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "activeHalfyear")]
pub active_halfyear: Option<i64>,
#[doc = "The amount of users that signed in at least once in the last 30 days."]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "activeMonth")]
pub active_month: Option<i64>,
#[doc = "The total amount of on this server registered users."]
#[serde(skip_serializing_if = "Option::is_none")]
pub total: Option<i64>,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo10Usage {
#[doc = "The amount of comments that were made by users that are registered on this server."]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "localComments")]
pub local_comments: Option<i64>,
#[doc = "The amount of posts that were made by users that are registered on this server."]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "localPosts")]
pub local_posts: Option<i64>,
#[doc = "statistics about the users of this server."]
pub users: NodeInfo10UsageUsers,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo10 {
#[doc = "The schema version, must be 1.0."]
pub version: String,
#[doc = "Free form key value pairs for software specific values. Clients should not rely on any "]
#[doc = "specific key present."]
pub metadata: HashMap<String, serde_json::Value>,
#[doc = "Whether this server allows open self-registration."]
#[serde(rename = "openRegistrations")]
pub open_registrations: bool,
#[doc = "The protocols supported on this server."]
pub protocols: NodeInfo10Protocols,
#[doc = "The third party sites this server can connect to via their application API."]
pub services: NodeInfo10Services,
#[doc = "Metadata about server software in use."]
pub software: NodeInfo10Protocols,
#[doc = "Usage statistics for this server."]
pub usage: NodeInfo10Usage,
}

View File

@ -0,0 +1,23 @@
use crate::version_1_0::{
NodeInfo10Protocols, NodeInfo10Services, NodeInfo10Software, NodeInfo10Usage,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo11 {
#[doc = "Free form key value pairs for software specific values. Clients should not rely on any "]
#[doc = "specific key present."]
pub metadata: HashMap<String, serde_json::Value>,
#[doc = "Whether this server allows open self-registration."]
#[serde(rename = "openRegistrations")]
pub open_registrations: bool,
#[doc = "The protocols supported on this server."]
pub protocols: NodeInfo10Protocols,
#[doc = "The third party sites this server can connect to via their application API."]
pub services: NodeInfo10Services,
#[doc = "Metadata about server software in use."]
pub software: NodeInfo10Software,
#[doc = "Usage statistics for this server."]
pub usage: NodeInfo10Usage,
}

View File

@ -0,0 +1,21 @@
use crate::version_1_0::{NodeInfo10Services, NodeInfo10Software, NodeInfo10Usage};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo20 {
#[doc = "Free form key value pairs for software specific values. Clients should not rely on any "]
#[doc = "specific key present."]
pub metadata: HashMap<String, serde_json::Value>,
#[doc = "Whether this server allows open self-registration."]
#[serde(rename = "openRegistrations")]
pub open_registrations: bool,
#[doc = "The protocols supported on this server."]
pub protocols: HashSet<String>,
#[doc = "The third party sites this server can connect to via their application API."]
pub services: NodeInfo10Services,
#[doc = "Metadata about server software in use."]
pub software: NodeInfo10Software,
#[doc = "Usage statistics for this server."]
pub usage: NodeInfo10Usage,
}

View File

@ -0,0 +1,35 @@
use crate::version_1_0::{NodeInfo10Services, NodeInfo10Usage};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo21Software {
#[doc = "The url of the homepage of this server software."]
#[serde(skip_serializing_if = "Option::is_none")]
pub homepage: Option<String>,
#[doc = "The canonical name of this server software."]
pub name: String,
#[doc = "The url of the source code repository of this server software."]
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option<String>,
#[doc = "The version of this server software."]
pub version: String,
}
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct NodeInfo21 {
#[doc = "Free form key value pairs for software specific values. Clients should not rely on any "]
#[doc = "specific key present."]
pub metadata: HashMap<String, serde_json::Value>,
#[doc = "Whether this server allows open self-registration."]
#[serde(rename = "openRegistrations")]
pub open_registrations: bool,
#[doc = "The protocols supported on this server."]
pub protocols: HashSet<String>,
#[doc = "The third party sites this server can connect to via their application API."]
pub services: NodeInfo10Services,
#[doc = "Metadata about server software in use."]
pub software: NodeInfo21Software,
#[doc = "Usage statistics for this server."]
pub usage: NodeInfo10Usage,
}

9
ext_webfinger/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "magnetar_webfinger"
version = "0.1.0"
edition = "2021"
[dependencies]
magnetar_core = { path = "../core", version = "0.1" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

1
ext_webfinger/src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod webfinger;

View File

@ -1,13 +1,13 @@
use crate::web_model::content_type::{ContentActivityStreams, ContentHtml}; use magnetar_core::web_model::acct::Acct;
use crate::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage}; use magnetar_core::web_model::content_type::{ContentActivityStreams, ContentHtml};
use serde::de::Error; use magnetar_core::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage};
use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Serialize};
use std::borrow::Cow;
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct WebFinger { pub struct WebFinger {
pub subject: WebFingerSubject, pub subject: WebFingerSubject,
pub aliases: Vec<WebFingerSubject>, #[serde(skip_serializing_if = "Option::is_none")]
pub aliases: Option<Vec<WebFingerSubject>>,
pub links: Vec<WebFingerRel>, pub links: Vec<WebFingerRel>,
} }
@ -40,75 +40,15 @@ pub enum WebFingerRel {
}, },
} }
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Acct(String);
impl Acct {
pub fn new(uri_without_acct: Cow<'_, str>) -> Self {
Acct(uri_without_acct.to_string())
}
}
impl From<&str> for Acct {
fn from(value: &str) -> Self {
Acct(value.strip_prefix("acct:").unwrap_or(value).to_string())
}
}
impl AsRef<str> for Acct {
fn as_ref(&self) -> &str {
&self.0
}
}
impl Serialize for Acct {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&format!("acct:{}", self.0))
}
}
impl<'de> Deserialize<'de> for Acct {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let acct = String::deserialize(deserializer)?;
if let Some(rem) = acct.strip_prefix("acct:") {
Ok(Acct(rem.to_owned()))
} else {
Err(Error::custom(
"Missing acct protocol for account!".to_owned(),
))
}
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::web_model::content_type::{ContentActivityStreams, ContentHtml}; use crate::webfinger::WebFingerSubject::Url;
use crate::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage}; use crate::webfinger::{WebFinger, WebFingerRel, WebFingerSubject};
use crate::web_model::webfinger::WebFingerSubject::Url; use magnetar_core::web_model::acct::Acct;
use crate::web_model::webfinger::{Acct, WebFinger, WebFingerRel, WebFingerSubject}; use magnetar_core::web_model::content_type::{ContentActivityStreams, ContentHtml};
use magnetar_core::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage};
use serde_json::json; use serde_json::json;
#[test]
fn should_remove_acct_prefix() {
let json = json!("acct:natty@tech.lgbt");
let acct: Acct = serde_json::from_value(json).unwrap();
assert_eq!(acct, Acct("natty@tech.lgbt".to_owned()))
}
#[test]
fn should_add_acct_prefix() {
let acct = Acct("natty@tech.lgbt".to_owned());
let json = serde_json::to_value(acct).unwrap();
assert_eq!(json, json!("acct:natty@tech.lgbt"));
}
#[test] #[test]
fn should_parse_webfinger() { fn should_parse_webfinger() {
let json = json!({ let json = json!({
@ -139,10 +79,10 @@ mod test {
let real = WebFinger { let real = WebFinger {
subject: WebFingerSubject::Acct(Acct::new("natty@tech.lgbt".into())), subject: WebFingerSubject::Acct(Acct::new("natty@tech.lgbt".into())),
aliases: vec![ aliases: Some(vec![
Url("https://tech.lgbt/@natty".to_owned()), Url("https://tech.lgbt/@natty".to_owned()),
Url("https://tech.lgbt/users/natty".to_owned()), Url("https://tech.lgbt/users/natty".to_owned()),
], ]),
links: vec![ links: vec![
WebFingerRel::RelWebFingerProfilePage { WebFingerRel::RelWebFingerProfilePage {
rel: RelWebFingerProfilePage, rel: RelWebFingerProfilePage,

163
src/config.rs Normal file
View File

@ -0,0 +1,163 @@
use anyhow::anyhow;
use serde::Deserialize;
use std::fmt::{Display, Formatter};
use std::net::IpAddr;
use tracing::info;
#[derive(Deserialize, Debug)]
#[non_exhaustive]
pub struct MagnetarNetworking {
pub host: String,
pub port: u16,
pub bind_addr: IpAddr,
pub protocol: MagnetarNetworkingProtocol,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum MagnetarNetworkingProtocol {
Http,
Https,
}
impl AsRef<str> for MagnetarNetworkingProtocol {
fn as_ref(&self) -> &str {
match *self {
MagnetarNetworkingProtocol::Http => "http",
MagnetarNetworkingProtocol::Https => "https",
}
}
}
impl Display for MagnetarNetworkingProtocol {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_ref())
}
}
fn env_host() -> String {
std::env::var("MAG_C_HOST")
.expect("MAG_C_HOST or \"networking.host\" in the default configuration must be set")
}
fn env_bind_addr() -> IpAddr {
std::env::var("MAG_C_BIND_ADDR")
.unwrap_or_else(|_| "::".to_owned())
.parse()
.map_err(|e| format!("Failed to parse \"MAG_C_BIND_ADDR\": {e}"))
.unwrap()
}
fn env_port() -> u16 {
std::env::var("MAG_C_PORT")
.unwrap_or_else(|_| "4939".to_owned())
.parse()
.expect("MAG_C_PORT must be a valid port number")
}
fn env_protocol() -> MagnetarNetworkingProtocol {
match std::env::var("MAG_C_PROTOCOL")
.unwrap_or_else(|_| "https".to_owned())
.to_lowercase()
.as_str()
{
"http" => MagnetarNetworkingProtocol::Http,
"https" => MagnetarNetworkingProtocol::Https,
_ => panic!("MAG_C_PROTOCOL must be a valid protocol"),
}
}
impl Default for MagnetarNetworking {
fn default() -> Self {
MagnetarNetworking {
host: env_host(),
bind_addr: env_bind_addr(),
port: env_port(),
protocol: env_protocol(),
}
}
}
#[derive(Deserialize, Debug)]
#[non_exhaustive]
pub struct MagnetarBranding {
pub name: String,
pub version: String,
pub homepage: String,
pub repository: String,
}
fn env_brand_name() -> String {
std::env::var("MAG_C_BR_NAME").unwrap_or_else(|_| "magnetar".to_owned())
}
fn env_brand_version() -> String {
std::env::var("MAG_C_BR_VERSION").unwrap_or_else(|_| env!("CARGO_PKG_VERSION").to_owned())
}
fn env_brand_homepage() -> String {
std::env::var("MAG_C_BR_HOMEPAGE")
.unwrap_or_else(|_| "https://git.astolfo.cool/natty/magnetar".to_owned())
}
fn env_brand_repository() -> String {
std::env::var("MAG_C_BR_REPOSITORY")
.unwrap_or_else(|_| "https://git.astolfo.cool/natty/magnetar".to_owned())
}
impl Default for MagnetarBranding {
fn default() -> Self {
MagnetarBranding {
name: env_brand_name(),
version: env_brand_version(),
homepage: env_brand_homepage(),
repository: env_brand_repository(),
}
}
}
#[derive(Deserialize, Debug)]
#[non_exhaustive]
pub struct MagnetarData {
pub database_url: String,
}
fn env_database_url() -> String {
std::env::var("MAG_C_DATABASE_URL")
.or_else(|_| std::env::var("DATABASE_URL"))
.expect("MAG_C_HOST, DATABASE_URL or \"data.database_url\" in the default configuration must be set")
}
impl Default for MagnetarData {
fn default() -> Self {
MagnetarData {
database_url: env_database_url(),
}
}
}
#[derive(Deserialize, Debug, Default)]
#[non_exhaustive]
pub struct MagnetarConfig {
#[serde(default)]
pub networking: MagnetarNetworking,
#[serde(default)]
pub branding: MagnetarBranding,
#[serde(default)]
pub data: MagnetarData,
}
pub fn load_config() -> anyhow::Result<MagnetarConfig> {
let path =
std::env::var("MAG_CONFIG_PATH").unwrap_or_else(|_| "config/default.toml".to_owned());
let str_cfg =
std::fs::read_to_string(path).map_err(|e| anyhow!("Failed to load configuration: {e}"))?;
let config =
toml::from_str(&str_cfg).map_err(|e| anyhow!("Failed to parse configuration: {e}"))?;
info!("Loaded configuration: {config:#?}");
Ok(config)
}

View File

@ -1,9 +1,14 @@
pub mod config;
pub mod nodeinfo;
pub mod util;
pub mod webfinger; pub mod webfinger;
use anyhow::{anyhow, Context}; use crate::nodeinfo::{handle_nodeinfo, handle_nodeinfo_20, handle_nodeinfo_21};
use anyhow::anyhow;
use axum::routing::get; use axum::routing::get;
use axum::Router; use axum::Router;
use dotenvy::dotenv; use dotenvy::dotenv;
use magnetar_calckey_model::{CalckeyModel, ConnectorConfig};
use std::net::SocketAddr; use std::net::SocketAddr;
use tower_http::cors::{Any, CorsLayer}; use tower_http::cors::{Any, CorsLayer};
use tower_http::trace::TraceLayer; use tower_http::trace::TraceLayer;
@ -23,15 +28,29 @@ async fn main() -> anyhow::Result<()> {
.with_test_writer() .with_test_writer()
.init(); .init();
let port: u16 = std::env::var("SERVER_PORT") let config = &*Box::leak::<'static>(Box::new(config::load_config()?));
.unwrap_or_else(|_| "4939".to_string())
.parse()
.context("SERVER_PORT not a number")?;
let well_known_router = Router::new().route("/webfinger", get(webfinger::handle_webfinger)); let db = CalckeyModel::new(ConnectorConfig {
url: config.data.database_url.clone(),
})
.await?;
let well_known_router = Router::new()
.route(
"/webfinger",
get(webfinger::handle_webfinger).with_state((config, db)),
)
.route("/nodeinfo", get(handle_nodeinfo));
let nodeinfo_router = Router::new()
.with_state(config)
.route("/2.0", get(handle_nodeinfo_20))
.route("/2.1", get(handle_nodeinfo_21));
let app = Router::new() let app = Router::new()
.nest("/.well-known", well_known_router) .nest("/.well-known", well_known_router)
.nest("/nodeinfo", nodeinfo_router)
.with_state(config)
.layer( .layer(
CorsLayer::new() CorsLayer::new()
.allow_headers(Any) .allow_headers(Any)
@ -40,7 +59,7 @@ async fn main() -> anyhow::Result<()> {
) )
.layer(TraceLayer::new_for_http()); .layer(TraceLayer::new_for_http());
let addr = SocketAddr::from(([0, 0, 0, 0], port)); let addr = SocketAddr::from((config.networking.bind_addr, config.networking.port));
info!("Serving on: {addr}"); info!("Serving on: {addr}");
axum::Server::bind(&addr) axum::Server::bind(&addr)
.serve(app.into_make_service()) .serve(app.into_make_service())

93
src/nodeinfo.rs Normal file
View File

@ -0,0 +1,93 @@
use crate::config::MagnetarConfig;
use axum::extract::State;
use axum::Json;
use magnetar_core::web_model::rel::{RelNodeInfo20, RelNodeInfo21};
use magnetar_core::web_model::Rel;
use magnetar_nodeinfo::version_1_0::{
NodeInfo10Services, NodeInfo10Software, NodeInfo10Usage, NodeInfo10UsageUsers,
};
use magnetar_nodeinfo::version_2_0::NodeInfo20;
use magnetar_nodeinfo::version_2_1::{NodeInfo21, NodeInfo21Software};
use serde::Serialize;
use std::collections::{HashMap, HashSet};
const NODEINFO_PATH: &str = "/nodeinfo";
#[derive(Clone, Debug, Serialize)]
pub struct NodeInfoLink {
rel: &'static str,
href: String,
}
pub async fn handle_nodeinfo(
State(config): State<&'static MagnetarConfig>,
) -> Json<Vec<NodeInfoLink>> {
Json(vec![
NodeInfoLink {
href: format!(
"{}://{}/nodeinfo/2.0",
config.networking.protocol, config.networking.host
),
rel: RelNodeInfo20.rel(),
},
NodeInfoLink {
href: format!(
"{}://{}/nodeinfo/2.1",
config.networking.protocol, config.networking.host
),
rel: RelNodeInfo21.rel(),
},
])
}
pub async fn handle_nodeinfo_21(State(config): State<&'static MagnetarConfig>) -> Json<NodeInfo21> {
Json(NodeInfo21 {
software: NodeInfo21Software {
name: config.branding.name.clone(),
version: config.branding.version.clone(),
homepage: Some(config.branding.homepage.clone()),
repository: Some(config.branding.repository.clone()),
},
protocols: HashSet::from(["activitypub".to_owned()]),
services: NodeInfo10Services {
inbound: HashSet::new(),
outbound: HashSet::new(),
},
open_registrations: false,
usage: NodeInfo10Usage {
users: NodeInfo10UsageUsers {
total: Some(0),
active_halfyear: Some(0),
active_month: Some(0),
},
local_posts: Some(0),
local_comments: Some(0),
},
metadata: HashMap::new(),
})
}
pub async fn handle_nodeinfo_20(State(config): State<&'static MagnetarConfig>) -> Json<NodeInfo20> {
Json(NodeInfo20 {
software: NodeInfo10Software {
name: config.branding.name.clone(),
version: config.branding.version.clone(),
},
protocols: HashSet::from(["activitypub".to_owned()]),
services: NodeInfo10Services {
inbound: HashSet::new(),
outbound: HashSet::new(),
},
open_registrations: false,
usage: NodeInfo10Usage {
users: NodeInfo10UsageUsers {
total: Some(0),
active_halfyear: Some(0),
active_month: Some(0),
},
local_posts: Some(0),
local_comments: None,
},
metadata: HashMap::new(),
})
}

98
src/util.rs Normal file
View File

@ -0,0 +1,98 @@
use anyhow::anyhow;
use magnetar_core::web_model::acct::Acct;
use percent_encoding::percent_decode_str;
use std::borrow::Cow;
#[derive(Clone, Debug)]
pub struct FediverseTag {
pub name: String,
pub host: Option<String>,
}
impl<S1: AsRef<str>, S2: AsRef<str>> From<(S1, Option<S2>)> for FediverseTag {
fn from((name, host): (S1, Option<S2>)) -> Self {
Self {
name: name.as_ref().to_owned(),
host: host.as_ref().map(S2::as_ref).map(str::to_owned),
}
}
}
impl From<FediverseTag> for Acct {
fn from(value: FediverseTag) -> Self {
value.to_string().into()
}
}
impl ToString for FediverseTag {
fn to_string(&self) -> String {
if let Some(ref host) = self.host {
format!("{}@{host}", self.name)
} else {
self.name.clone()
}
}
}
pub fn lenient_parse_acct(acct: &Acct) -> anyhow::Result<FediverseTag> {
lenient_parse_tag(acct.as_ref())
}
fn split_tag_inner(tag: impl AsRef<str>) -> (String, Option<String>) {
let tag = tag.as_ref();
let tag = tag.strip_prefix('@').unwrap_or(tag.as_ref());
match tag.split_once('@') {
Some((name, host)) if name.is_empty() => (host.to_owned(), None),
Some((name, host)) => (name.to_owned(), Some(host.to_owned())),
None => (tag.to_owned(), None),
}
}
fn validate_tag_inner((name, host): (&str, Option<&str>)) -> anyhow::Result<()> {
if name
.chars()
.any(|c| !c.is_alphanumeric() && c != '-' && c != '.')
{
return Err(anyhow!("Invalid char in tag: {name}"));
}
if let Some(host_str) = host {
if host_str
.chars()
.any(|c| c.is_control() || c.is_whitespace() || c == '/' || c == '#')
{
return Err(anyhow!("Invalid char in tag: {name}"));
}
}
Ok(())
}
pub fn lenient_parse_tag(tag: impl AsRef<str>) -> anyhow::Result<FediverseTag> {
let (name, host) = split_tag_inner(tag);
validate_tag_inner((&name, host.as_ref().map(String::as_ref)))?;
Ok(FediverseTag { name, host })
}
pub fn lenient_parse_acct_decode(acct: &Acct) -> anyhow::Result<FediverseTag> {
lenient_parse_tag_decode(acct.as_ref())
}
pub fn lenient_parse_tag_decode(tag: impl AsRef<str>) -> anyhow::Result<FediverseTag> {
let (name, host) = split_tag_inner(tag);
let name_decoded = percent_decode_str(&name).decode_utf8()?;
let host_decoded = host
.map(|host| percent_decode_str(&host).decode_utf8().map(Cow::into_owned))
.transpose()?;
validate_tag_inner((&name_decoded, host_decoded.as_deref()))?;
Ok(FediverseTag {
name: name_decoded.into_owned(),
host: host_decoded,
})
}

View File

@ -1,10 +1,17 @@
use axum::extract::Query; use crate::config::MagnetarConfig;
use crate::util::{lenient_parse_acct_decode, FediverseTag};
use axum::extract::{Query, State};
use axum::http::StatusCode; use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::Json; use axum::Json;
use magnetar_core::web_model::content_type::{ContentActivityStreams, ContentHtml}; use hyper::header;
use magnetar_calckey_model::CalckeyModel;
use magnetar_core::web_model::acct::Acct;
use magnetar_core::web_model::content_type::{ContentActivityStreams, ContentHtml, ContentJrdJson};
use magnetar_core::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage}; use magnetar_core::web_model::rel::{RelOStatusSubscribe, RelSelf, RelWebFingerProfilePage};
use magnetar_core::web_model::webfinger::{Acct, WebFinger, WebFingerRel, WebFingerSubject}; use magnetar_webfinger::webfinger::{WebFinger, WebFingerRel, WebFingerSubject};
use serde::Deserialize; use serde::Deserialize;
use tracing::error;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct WebFingerQuery { pub struct WebFingerQuery {
@ -12,41 +19,108 @@ pub struct WebFingerQuery {
rel: Option<Vec<String>>, rel: Option<Vec<String>>,
} }
// TODO: Filter by rel
pub async fn handle_webfinger( pub async fn handle_webfinger(
Query(WebFingerQuery { resource, rel, .. }): Query<WebFingerQuery>, Query(WebFingerQuery { resource, rel, .. }): Query<WebFingerQuery>,
) -> Result<Json<WebFinger>, StatusCode> { State((config, ck)): State<(&'static MagnetarConfig, CalckeyModel)>,
) -> Result<impl IntoResponse, StatusCode> {
let resource = match resource { let resource = match resource {
acct @ WebFingerSubject::Acct(_) => acct, acct @ WebFingerSubject::Acct(_) => acct,
// Leniently re-add the acct // Leniently re-add the acct
WebFingerSubject::Url(url) if url.contains('@') && !url.starts_with("http") => { WebFingerSubject::Url(url) if !url.starts_with("http:") && !url.starts_with("https:") => {
WebFingerSubject::Acct(Acct::new(url.into())) WebFingerSubject::Acct(Acct::new(url.into()))
} }
other => other, other => other,
}; };
println!("{resource:?}"); let user = match resource {
WebFingerSubject::Acct(acct) => {
let tag = lenient_parse_acct_decode(&acct).map_err(|e| {
error!("Failed to parse tag: {e}");
StatusCode::UNPROCESSABLE_ENTITY
})?;
Ok(Json(WebFinger { ck.get_user_by_tag(
subject: WebFingerSubject::Acct("natty@tech.lgbt".into()), &tag.name,
aliases: vec![ tag.host
WebFingerSubject::Url("https://tech.lgbt/@natty".to_owned()), .filter(|host| *host != config.networking.host)
WebFingerSubject::Url("https://tech.lgbt/users/natty".to_owned()), .as_deref(),
], )
links: vec![ .await
WebFingerRel::RelWebFingerProfilePage { .map_err(|e| {
error!("Data error: {e}");
StatusCode::INTERNAL_SERVER_ERROR
})?
}
// Kinda a
WebFingerSubject::Url(url) => ck.get_user_by_uri(&url).await.map_err(|e| {
error!("Data error: {e}");
StatusCode::INTERNAL_SERVER_ERROR
})?,
};
if user.is_none() {
return Err(StatusCode::NOT_FOUND);
}
let user = user.unwrap();
let tag = FediverseTag::from((
&user.username,
user.host.as_ref().or(Some(&config.networking.host)),
));
let mut links = Vec::new();
let mut aliases = Vec::new();
match tag.host {
Some(ref host) if host != &config.networking.host => {
if let Some(uri) = user.uri {
links.push(WebFingerRel::RelSelf {
rel: RelSelf,
content_type: ContentActivityStreams,
href: uri,
});
}
}
_ => {
links.push(WebFingerRel::RelOStatusSubscribe {
rel: RelOStatusSubscribe,
template: format!(
"{}://{}/authorize-follow?acct={{uri}}",
config.networking.protocol, config.networking.host
),
});
let user_url = format!(
"{}://{}/@{}",
config.networking.protocol, config.networking.host, tag.name
);
links.push(WebFingerRel::RelWebFingerProfilePage {
rel: RelWebFingerProfilePage, rel: RelWebFingerProfilePage,
content_type: ContentHtml, content_type: ContentHtml,
href: "https://tech.lgbt/@natty".to_owned(), href: user_url.clone(),
}, });
WebFingerRel::RelSelf {
aliases.push(WebFingerSubject::Url(user_url));
links.push(WebFingerRel::RelSelf {
rel: RelSelf, rel: RelSelf,
content_type: ContentActivityStreams, content_type: ContentActivityStreams,
href: "https://tech.lgbt/users/natty".to_owned(), href: format!(
}, "{}://{}/users/{}",
WebFingerRel::RelOStatusSubscribe { config.networking.protocol, config.networking.host, user.id
rel: RelOStatusSubscribe, ),
template: "https://tech.lgbt/authorize_interaction?uri={uri}".to_owned(), });
}, }
], }
}))
Ok((
[(header::CONTENT_TYPE, ContentJrdJson.as_ref())],
Json(WebFinger {
subject: WebFingerSubject::Acct(tag.into()),
aliases: Some(aliases),
links,
}),
))
} }