├── .config ├── cypress-devcontainer.yml ├── docker.env ├── docker_example.env ├── docker_example.yml └── example.yml ├── .devcontainer ├── Dockerfile ├── cert.sh ├── compose.yml ├── devcontainer.json ├── docker.env ├── misskey │ └── .config │ │ └── default.yml └── nginx │ └── conf │ └── server.conf ├── .dockerignore ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── 01_bug-report.yml │ └── 02_feature_request.yml └── workflows │ ├── docker.yml │ ├── dockle.yml │ ├── on-release-created.yml │ └── rust-clippy.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── LICENSE-APACHE ├── LICENSE-MIT ├── Makefile ├── README.md ├── TODO.md ├── compose.local.yml ├── docs ├── feature.md └── install.md ├── rustfmt.toml └── src ├── cli ├── command.rs ├── config │ ├── mod.rs │ └── show.rs ├── id │ ├── gen.rs │ ├── mod.rs │ └── parse.rs ├── mod.rs ├── note │ ├── delete.rs │ └── mod.rs ├── remote │ ├── gone.rs │ ├── mod.rs │ ├── suspend.rs │ └── unsuspend.rs ├── search │ ├── deploy.rs │ ├── drop.rs │ ├── get.rs │ ├── health.rs │ ├── list.rs │ ├── mod.rs │ └── redeploy.rs ├── style.rs ├── user │ ├── cull.rs │ ├── delete.rs │ ├── mod.rs │ └── prune.rs └── vapid │ ├── generate.rs │ └── mod.rs ├── config.rs ├── consts.rs ├── db ├── mod.rs ├── postgres.rs └── redis.rs ├── entities ├── abuse_report_notification_recipient.rs ├── abuse_user_report.rs ├── access_token.rs ├── ad.rs ├── announcement.rs ├── announcement_read.rs ├── antenna.rs ├── app.rs ├── auth_session.rs ├── avatar_decoration.rs ├── blocking.rs ├── bubble_game_record.rs ├── channel.rs ├── channel_favorite.rs ├── channel_following.rs ├── channel_note_pining.rs ├── clip.rs ├── clip_favorite.rs ├── clip_note.rs ├── drive_file.rs ├── drive_folder.rs ├── emoji.rs ├── flash.rs ├── flash_like.rs ├── follow_request.rs ├── following.rs ├── gallery_like.rs ├── gallery_post.rs ├── hashtag.rs ├── instance.rs ├── messaging_message.rs ├── meta.rs ├── migrations.rs ├── mod.rs ├── moderation_log.rs ├── muting.rs ├── note.rs ├── note_favorite.rs ├── note_reaction.rs ├── note_thread_muting.rs ├── note_unread.rs ├── note_watching.rs ├── page.rs ├── page_like.rs ├── password_reset_request.rs ├── poll.rs ├── poll_vote.rs ├── prelude.rs ├── promo_note.rs ├── promo_read.rs ├── registration_ticket.rs ├── registry_item.rs ├── relay.rs ├── renote_muting.rs ├── retention_aggregation.rs ├── reversi_game.rs ├── reversi_matching.rs ├── role.rs ├── role_assignment.rs ├── sea_orm_active_enums.rs ├── signin.rs ├── sw_subscription.rs ├── system_webhook.rs ├── used_username.rs ├── user.rs ├── user_group.rs ├── user_group_invitation.rs ├── user_group_invite.rs ├── user_group_joining.rs ├── user_ip.rs ├── user_keypair.rs ├── user_list.rs ├── user_list_favorite.rs ├── user_list_membership.rs ├── user_memo.rs ├── user_note_pining.rs ├── user_pending.rs ├── user_profile.rs ├── user_publickey.rs ├── user_security_key.rs └── webhook.rs ├── main.rs └── util ├── id ├── aid.rs ├── aidx.rs ├── meid.rs ├── mod.rs ├── objectid.rs └── ulid.rs ├── mod.rs ├── radix.rs └── vapid.rs /.config/docker.env: -------------------------------------------------------------------------------- 1 | # misskey settings 2 | # MISSKEY_URL=https://example.tld/ 3 | 4 | # db settings 5 | POSTGRES_PASSWORD=postgres 6 | # DATABASE_PASSWORD=${POSTGRES_PASSWORD} 7 | POSTGRES_USER=postgres 8 | # DATABASE_USER=${POSTGRES_USER} 9 | POSTGRES_DB=misskey 10 | # DATABASE_DB=${POSTGRES_DB} 11 | DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}" 12 | -------------------------------------------------------------------------------- /.config/docker_example.env: -------------------------------------------------------------------------------- 1 | # misskey settings 2 | # MISSKEY_URL=https://example.tld/ 3 | 4 | # db settings 5 | POSTGRES_PASSWORD=example-misskey-pass 6 | # DATABASE_PASSWORD=${POSTGRES_PASSWORD} 7 | POSTGRES_USER=example-misskey-user 8 | # DATABASE_USER=${POSTGRES_USER} 9 | POSTGRES_DB=misskey 10 | # DATABASE_DB=${POSTGRES_DB} 11 | DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}" 12 | -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.83.0-bookworm 2 | 3 | RUN rustup component add rustfmt clippy 4 | RUN cargo install sea-orm-cli -------------------------------------------------------------------------------- /.devcontainer/cert.sh: -------------------------------------------------------------------------------- 1 | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx/certs/server.key -out nginx/certs/server.crt -subj "/CN=localhost" -------------------------------------------------------------------------------- /.devcontainer/compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | notectl-dev: 3 | build: 4 | context: .. 5 | dockerfile: .devcontainer/Dockerfile 6 | volumes: 7 | - ..:/workspaces/notectl-dev 8 | working_dir: /workspaces/notectl-dev:cached 9 | command: sleep infinity 10 | networks: 11 | - internal_network 12 | - external_network 13 | 14 | nginx: 15 | image: nginx:alpine 16 | restart: unless-stopped 17 | ports: 18 | - "443:443" 19 | volumes: 20 | - ./nginx/conf:/etc/nginx/conf.d 21 | - ./nginx/certs:/etc/nginx/certs 22 | depends_on: 23 | - misskey 24 | networks: 25 | - internal_network 26 | - external_network 27 | 28 | misskey: 29 | image: misskey/misskey:latest 30 | restart: always 31 | depends_on: 32 | db: 33 | condition: service_healthy 34 | redis: 35 | condition: service_healthy 36 | ports: ["3000:3000"] # enable this if you want to access directly 37 | networks: 38 | - internal_network 39 | - external_network 40 | volumes: 41 | - ./misskey/.config/default.yml:/misskey/.config/default.yml:ro 42 | - ./misskey/files:/misskey/files 43 | environment: 44 | - VIRTUAL_HOST=~^.*$$ # marker for lb 45 | - VIRTUAL_PORT=3000 # target port for lb 46 | 47 | redis: 48 | restart: always 49 | image: redis:7-alpine 50 | networks: 51 | - internal_network 52 | volumes: 53 | - ./redis1:/data 54 | healthcheck: 55 | test: "redis-cli ping" 56 | interval: 5s 57 | retries: 20 58 | 59 | db: 60 | restart: always 61 | image: postgres:15-alpine 62 | networks: 63 | - internal_network 64 | env_file: 65 | - docker.env 66 | volumes: 67 | - ./pg1:/var/lib/postgresql/data 68 | healthcheck: 69 | test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" 70 | interval: 5s 71 | retries: 20 72 | 73 | meilisearch: 74 | restart: unless-stopped 75 | image: getmeili/meilisearch:latest 76 | ports: 77 | - "7700:7700" 78 | environment: 79 | - MEILI_NO_ANALYTICS=true 80 | - MEILI_ENV=production 81 | - MEILI_MASTER_KEY= 82 | networks: 83 | - internal_network 84 | - external_network 85 | volumes: 86 | - ./meilisearch:/meili_data 87 | 88 | networks: 89 | internal_network: 90 | internal: true 91 | external_network: 92 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notectl development container", 3 | "dockerComposeFile": "compose.yml", 4 | "service": "notectl-dev", 5 | "workspaceFolder": "/workspaces/notectl-dev", 6 | "remoteUser": "root", 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "rust-lang.rust-analyzer", 11 | "tamasfe.even-better-toml", 12 | "vadimcn.vscode-lldb", 13 | "oderwat.indent-rainbow", 14 | "dustypomerleau.rust-syntax", 15 | "github.vscode-github-actions" 16 | ] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.devcontainer/docker.env: -------------------------------------------------------------------------------- 1 | # db settings 2 | POSTGRES_PASSWORD=postgres # You may change it but it's mostly safe as is, because db is completely private. 3 | POSTGRES_USER=postgres 4 | POSTGRES_DB=misskey 5 | -------------------------------------------------------------------------------- /.devcontainer/misskey/.config/default.yml: -------------------------------------------------------------------------------- 1 | #━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2 | # Misskey configuration 3 | #━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4 | 5 | # ┌─────┐ 6 | #───┘ URL └───────────────────────────────────────────────────── 7 | 8 | # Final accessible URL seen by a user. 9 | url: https://misskey.local/ 10 | 11 | # ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE 12 | # URL SETTINGS AFTER THAT! 13 | 14 | # ┌───────────────────────┐ 15 | #───┘ Port and TLS settings └─────────────────────────────────── 16 | 17 | # 18 | # Misskey requires a reverse proxy to support HTTPS connections. 19 | # 20 | # +----- https://example.tld/ ------------+ 21 | # +------+ |+-------------+ +----------------+| 22 | # | User | ---> || Proxy (443) | ---> | Misskey (3000) || 23 | # +------+ |+-------------+ +----------------+| 24 | # +---------------------------------------+ 25 | # 26 | # You need to set up a reverse proxy. (e.g. nginx) 27 | # An encrypted connection with HTTPS is highly recommended 28 | # because tokens may be transferred in GET requests. 29 | 30 | # The port that your Misskey server should listen on. 31 | port: 3000 32 | 33 | # ┌──────────────────────────┐ 34 | #───┘ PostgreSQL configuration └──────────────────────────────── 35 | 36 | db: 37 | host: db 38 | port: 5432 39 | 40 | # Database name 41 | db: misskey 42 | 43 | # Auth 44 | user: postgres 45 | pass: postgres 46 | 47 | # Whether disable Caching queries 48 | #disableCache: true 49 | 50 | # Extra Connection options 51 | #extra: 52 | # ssl: true 53 | 54 | dbReplications: false 55 | 56 | # You can configure any number of replicas here 57 | #dbSlaves: 58 | # - 59 | # host: 60 | # port: 61 | # db: 62 | # user: 63 | # pass: 64 | # - 65 | # host: 66 | # port: 67 | # db: 68 | # user: 69 | # pass: 70 | 71 | # ┌─────────────────────┐ 72 | #───┘ Redis configuration └───────────────────────────────────── 73 | 74 | redis: 75 | host: redis 76 | port: 6379 77 | #family: 0 # 0=Both, 4=IPv4, 6=IPv6 78 | #pass: example-pass 79 | #prefix: example-prefix 80 | #db: 1 81 | 82 | #redisForPubsub: 83 | # host: redis 84 | # port: 6379 85 | # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 86 | # #pass: example-pass 87 | # #prefix: example-prefix 88 | # #db: 1 89 | 90 | #redisForJobQueue: 91 | # host: redis 92 | # port: 6379 93 | # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 94 | # #pass: example-pass 95 | # #prefix: example-prefix 96 | # #db: 1 97 | 98 | #redisForTimelines: 99 | # host: redis 100 | # port: 6379 101 | # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 102 | # #pass: example-pass 103 | # #prefix: example-prefix 104 | # #db: 1 105 | 106 | # ┌───────────────────────────┐ 107 | #───┘ MeiliSearch configuration └───────────────────────────── 108 | 109 | #meilisearch: 110 | # host: meilisearch 111 | # port: 7700 112 | # apiKey: 'FN6sKuqo5nF8OTAj4kE3NDTZ' 113 | # ssl: false 114 | # index: 'localtest' 115 | # scope: 'global' 116 | 117 | # ┌───────────────┐ 118 | #───┘ ID generation └─────────────────────────────────────────── 119 | 120 | # You can select the ID generation method. 121 | # You don't usually need to change this setting, but you can 122 | # change it according to your preferences. 123 | 124 | # Available methods: 125 | # aid ... Short, Millisecond accuracy 126 | # aidx ... Millisecond accuracy 127 | # meid ... Similar to ObjectID, Millisecond accuracy 128 | # ulid ... Millisecond accuracy 129 | # objectid ... This is left for backward compatibility 130 | 131 | # ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE 132 | # ID SETTINGS AFTER THAT! 133 | 134 | id: 'aidx' 135 | 136 | # ┌────────────────┐ 137 | #───┘ Error tracking └────────────────────────────────────────── 138 | 139 | # Sentry is available for error tracking. 140 | # See the Sentry documentation for more details on options. 141 | 142 | #sentryForBackend: 143 | # enableNodeProfiling: true 144 | # options: 145 | # dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' 146 | 147 | #sentryForFrontend: 148 | # options: 149 | # dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0' 150 | 151 | # ┌─────────────────────┐ 152 | #───┘ Other configuration └───────────────────────────────────── 153 | 154 | # Whether disable HSTS 155 | #disableHsts: true 156 | 157 | # Number of worker processes 158 | #clusterLimit: 1 159 | 160 | # Job concurrency per worker 161 | # deliverJobConcurrency: 128 162 | # inboxJobConcurrency: 16 163 | 164 | # Job rate limiter 165 | # deliverJobPerSec: 128 166 | # inboxJobPerSec: 32 167 | 168 | # Job attempts 169 | # deliverJobMaxAttempts: 12 170 | # inboxJobMaxAttempts: 8 171 | 172 | # IP address family used for outgoing request (ipv4, ipv6 or dual) 173 | #outgoingAddressFamily: ipv4 174 | 175 | # Proxy for HTTP/HTTPS 176 | #proxy: http://127.0.0.1:3128 177 | 178 | proxyBypassHosts: 179 | - api.deepl.com 180 | - api-free.deepl.com 181 | - www.recaptcha.net 182 | - hcaptcha.com 183 | - challenges.cloudflare.com 184 | 185 | # Proxy for SMTP/SMTPS 186 | #proxySmtp: http://127.0.0.1:3128 # use HTTP/1.1 CONNECT 187 | #proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4 188 | #proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5 189 | 190 | # Media Proxy 191 | #mediaProxy: https://example.com/proxy 192 | 193 | # Proxy remote files (default: true) 194 | proxyRemoteFiles: true 195 | 196 | # Sign to ActivityPub GET request (default: true) 197 | signToActivityPubGet: true 198 | 199 | allowedPrivateNetworks: [ 200 | '127.0.0.1/32' 201 | ] 202 | 203 | # Upload or download file size limits (bytes) 204 | #maxFileSize: 262144000 205 | -------------------------------------------------------------------------------- /.devcontainer/nginx/conf/server.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 443 ssl; 3 | server_name misskey.local; 4 | 5 | ssl_certificate /etc/nginx/certs/server.crt; 6 | ssl_certificate_key /etc/nginx/certs/server.key; 7 | 8 | location / { 9 | proxy_pass http://misskey:3000; 10 | proxy_set_header Host $host; 11 | proxy_set_header X-Real-IP $remote_addr; 12 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 13 | proxy_set_header X-Forwarded-Proto https; 14 | proxy_set_header Upgrade $http_upgrade; 15 | proxy_set_header Connection upgrade; 16 | } 17 | } 18 | 19 | #server { 20 | # listen 443 ssl; 21 | # server_name misskey2.local; 22 | # 23 | # ssl_certificate /etc/nginx/certs/server.crt; 24 | # ssl_certificate_key /etc/nginx/certs/server.key; 25 | # 26 | # location / { 27 | # proxy_pass http://:3000; 28 | # proxy_set_header Host $host; 29 | # proxy_set_header X-Real-IP $remote_addr; 30 | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 31 | # proxy_set_header X-Forwarded-Proto https; 32 | # proxy_set_header Upgrade $http_upgrade; 33 | # proxy_set_header Connection upgrade; 34 | # } 35 | #} 36 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .config -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.yml, *.rs] 2 | indent_style = space 3 | indent_size = 2 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01_bug-report.yml: -------------------------------------------------------------------------------- 1 | name: Report a Bug 2 | description: Create a report to help us improve 3 | labels: ["bug?"] 4 | 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for reporting a bug. 10 | In order to avoid duplicate issues, please search to see if the problemm you found has already been reported. 11 | 12 | - type: textarea 13 | attributes: 14 | label: Summary 15 | description: Tell us what the bug is about 16 | validations: 17 | required: true 18 | 19 | - type: textarea 20 | attributes: 21 | label: Expected Behavior 22 | description: Tell us what should happen 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | attributes: 28 | label: Actual Behavior 29 | description: Tell us what happens instead 30 | validations: 31 | required: true 32 | 33 | - type: textarea 34 | attributes: 35 | label: Steps to Reproduce 36 | description: Tell us how to reproduce this bug 37 | validations: 38 | required: true 39 | 40 | - type: textarea 41 | attributes: 42 | label: Additional Information 43 | description: Tell us anything else you think we should know 44 | value: | 45 | * Software Name: 46 | * Software Version: 47 | * Operating System: 48 | * Machine's CPU Architecture: 49 | render: markdown 50 | validations: 51 | required: false 52 | 53 | - type: checkboxes 54 | attributes: 55 | label: Create a Pull Request 56 | options: 57 | - label: Yes, I will patch the bug myself and send a pull request 58 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/02_feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Suggest an idea for this project 3 | labels: ["feature"] 4 | 5 | body: 6 | - type: textarea 7 | attributes: 8 | label: Summary 9 | description: Tell us what the suggestion is 10 | validations: 11 | required: true 12 | 13 | - type: textarea 14 | attributes: 15 | label: Purpose 16 | description: Describe the specific problem or need you think this feature will solve, and who it will help. 17 | validations: 18 | required: true 19 | 20 | - type: checkboxes 21 | attributes: 22 | label: Create a Pull Request 23 | options: 24 | - label: Yes, I will patch the bug myself and send a pull request 25 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker Image 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build-and-publish: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v3 14 | 15 | - name: Set up QEMU 16 | uses: docker/setup-qemu-action@v2 17 | 18 | - name: Set up Docker Buildx 19 | uses: docker/setup-buildx-action@v2 20 | 21 | - name: Log in to GitHub Container Registry 22 | uses: docker/login-action@v2 23 | with: 24 | registry: ghcr.io 25 | username: ${{ github.actor }} 26 | password: ${{ secrets.GHCR_TOKEN }} 27 | 28 | - name: Extract version from tag 29 | id: extract_version 30 | run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV 31 | 32 | - name: Build and push Docker image 33 | uses: docker/build-push-action@v4 34 | with: 35 | context: . 36 | push: true 37 | tags: | 38 | ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.RELEASE_VERSION }} 39 | ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest 40 | 41 | - name: Post build info 42 | run: | 43 | echo "Docker image published:" 44 | echo "ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.RELEASE_VERSION }}" 45 | echo "ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest" 46 | -------------------------------------------------------------------------------- /.github/workflows/dockle.yml: -------------------------------------------------------------------------------- 1 | name: Dockle 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | pull_request: 8 | 9 | jobs: 10 | dockle: 11 | runs-on: ${{ matrix.runner }} 12 | strategy: 13 | matrix: 14 | include: 15 | - runner: ubuntu-latest 16 | platform: linux/amd64 17 | arch: amd64 18 | - runner: ubuntu-24.04-arm 19 | platform: linux/arm64 20 | arch: arm64 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v4 24 | 25 | - name: Set up QEMU 26 | uses: docker/setup-qemu-action@v2 27 | with: 28 | platforms: ${{ matrix.platform }} 29 | 30 | - name: Set up Docker Buildx 31 | uses: docker/setup-buildx-action@v2 32 | 33 | - name: Start Docker 34 | run: | 35 | docker --version 36 | sudo systemctl start docker 37 | sudo systemctl status docker 38 | 39 | - name: Build Docker image 40 | uses: docker/build-push-action@v4 41 | with: 42 | context: . 43 | push: false 44 | load: true 45 | platforms: ${{ matrix.platform }} 46 | tags: local/notectl:${{ github.sha }}-${{ matrix.arch}} 47 | 48 | - name: Run Dockle 49 | uses: goodwithtech/dockle-action@main 50 | with: 51 | image: local/notectl:${{ github.sha }}-${{ matrix.arch }} 52 | format: 'sarif' 53 | exit-code: '1' 54 | exit-level: 'error' 55 | 56 | - name: Clean up 57 | if: always() 58 | run: docker system prune -af 59 | -------------------------------------------------------------------------------- /.github/workflows/on-release-created.yml: -------------------------------------------------------------------------------- 1 | name: On Release Created (Publish binary) 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | include: 13 | - target: x86_64-unknown-linux-gnu 14 | platform: linux/amd64 15 | arch: x86_64 16 | - target: x86_64-unknown-linux-musl 17 | platform: linux/amd64 18 | arch: x86_64 19 | - target: aarch64-unknown-linux-gnu 20 | platform: linux/arm64 21 | arch: aarch64 22 | - target: aarch64-unknown-linux-musl 23 | platform: linux/arm64 24 | arch: aarch64 25 | - target: x86_64-unknown-freebsd 26 | platform: freebsd/amd64 27 | arch: x86_64 28 | - target: aarch64-apple-darwin 29 | platform: darwin/arm64 30 | arch: aarch64 31 | - target: x86_64-apple-darwin 32 | platform: darwin/amd64 33 | arch: x86_64 34 | - target: riscv64gc-unknown-linux-gnu 35 | platform: linux/riscv64 36 | arch: riscv64 37 | - target: riscv64gc-unknown-linux-musl 38 | platform: linux/riscv64 39 | arch: riscv64 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | 44 | - name: Set up Rust 45 | run: | 46 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 47 | export PATH="$HOME/.cargo/bin:$PATH" 48 | source $HOME/.cargo/env 49 | rustup default stable 50 | rustup update 51 | rustup component add clippy 52 | rustup target add ${{ matrix.target }} 53 | cargo install clippy-sarif sarif-fmt cross 54 | 55 | - name: Build binary 56 | run: cross build --release --target ${{ matrix.target }} 57 | 58 | - name: Package binary 59 | run: | 60 | mkdir -p artifacts 61 | cd target/release 62 | tar -czf ../../artifacts/notectl-${{ matrix.target }}-${{ github.event.release.tag_name }}-tar.gz notectl 63 | 64 | - name: Upload binary 65 | uses: softprops/action-gh-release@v1 66 | env: 67 | GITHUB_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 68 | with: 69 | files: | 70 | artifacts/notectl-${{ matrix.target }}-${{ github.event.release.tag_name }}-tar.gz 71 | -------------------------------------------------------------------------------- /.github/workflows/rust-clippy.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # rust-clippy is a tool that runs a bunch of lints to catch common 6 | # mistakes in your Rust code and help improve your Rust code. 7 | # More details at https://github.com/rust-lang/rust-clippy 8 | # and https://rust-lang.github.io/rust-clippy/ 9 | 10 | name: rust-clippy analyze 11 | 12 | on: 13 | push: 14 | branches: [ "develop" ] 15 | pull_request: 16 | # The branches below must be a subset of the branches above 17 | branches: [ "develop" ] 18 | 19 | jobs: 20 | rust-clippy-analyze: 21 | name: Run rust-clippy analyzing 22 | runs-on: ubuntu-latest 23 | permissions: 24 | contents: read 25 | security-events: write 26 | actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status 27 | steps: 28 | - name: Checkout code 29 | uses: actions/checkout@v4 30 | 31 | - name: Install Rust toolchain 32 | uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 33 | with: 34 | profile: minimal 35 | toolchain: stable 36 | components: clippy 37 | override: true 38 | 39 | - name: Install required cargo 40 | run: cargo install clippy-sarif sarif-fmt 41 | 42 | - name: Run rust-clippy 43 | run: 44 | cargo clippy 45 | --all-features 46 | --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt 47 | continue-on-error: true 48 | 49 | - name: Upload analysis results to GitHub 50 | uses: github/codeql-action/upload-sarif@v3 51 | with: 52 | sarif_file: rust-clippy-results.sarif 53 | wait-for-processing: true 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .env 3 | .devcontainer/meilisearch.env 4 | .devcontainer/pg1 5 | .devcontainer/pg2 6 | .devcontainer/redis1 7 | .devcontainer/redis2 8 | .devcontainer/nginx/certs 9 | .devcontainer/meilisearch 10 | .devcontainer/misskey/files 11 | /db 12 | /redis 13 | /meilisearch 14 | .config/default.yml 15 | .config/development.yml 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.2.1 2 | 3 | ## Release Date 4 | Unreleased 5 | 6 | ## Fix 7 | - `note delete`でデータ量が多い際メモリリークすることがある問題 8 | 9 | # 0.2.0 10 | 11 | ## Release Date 12 | 2025/03/02 13 | 14 | ## Feat 15 | - `user delete`で`username`を指定できるように 16 | - `note delete`で`visibility`を指定できるように 17 | - `note delete`で反応がないノートのみを削除できるように 18 | 19 | ## Fix 20 | 21 | # 0.1.3 22 | 23 | ## Release Date 24 | 2025/02/06 25 | 26 | ## Fix 27 | - バージョンの上げ忘れ 28 | 29 | # 0.1.2 30 | 31 | ## Release Date 32 | 2025/02/05 33 | 34 | ## Dev 35 | - editorconfigとrustfmtを改善 36 | 37 | ## Fix 38 | - opensslを0.10.70に 39 | - meilisearchが有効な場合に`note delete`を実行する際に、誤ってローカルの投稿が削除される問題を修正 40 | 41 | # 0.1.1 42 | 43 | ## Release Date 44 | 2025/1/12 45 | 46 | ## Fix 47 | - meilisearchが有効な場合に`note delete`を実行する際、ホスト指定が考慮されていなかった問題を修正 48 | 49 | 50 | # 0.1.0 51 | 52 | ## Release Date 53 | 2025/1/12 54 | 55 | ## Features 56 | - `user`コマンドを追加 57 | - `note`コマンドを追加 58 | - `config`コマンドを追加 59 | - `id`コマンドを追加 60 | - `search`コマンドを追加 61 | - `remote`コマンドを追加 62 | - `webpush`コマンドを追加 63 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING GUIDE for notectl [WIP] 2 | notectlのコントリビューションガイドです。 3 | まだ作成中です。 4 | 5 | ## 開発環境 6 | notectlの開発には以下のいずれかの方法を使用することができます。 7 | - [devcontainer](#devcontainer) 8 | - [ローカル](#ローカル環境で開発する) 9 | 10 | ### devcontainer 11 | devcontainerはVSCodeの拡張機能`Dev Containers(ms-azuretools.vscode-docker)`あるいはdevcontainer-cliとDocker Composeが必要です。 12 | デフォルトのコンテナ構成では、notectlのdevcontainerと、misskey、postgresql、redisの構成になっています。必要に応じてmeilisearchなどを有効にして下さい。 13 | 14 | ### ローカル環境で開発する 15 | 以下の環境が必要です。 16 | - Rust 1.81.0以降 17 | - sea-orm-cli 18 | 19 | また、MisskeyをローカルやDockerで動かす必要がある場合もあります。その際には次の手順を参考にローカルにMisskeyを立ててください。 20 | 参考: [Misskeyサーバーの作成](https://misskey-hub.net/ja/docs/for-admin/install/guides/) 21 | 22 | ## Issue 23 | イシューを作成する前に、以下の点を確認して下さい: 24 | - 重複を避けるため、Issueを作成する前に似たようなIssueがあるか確認してください 25 | - 質問やトラブルシューティングのためにIssueを利用しないでください 26 | - Issueはあくまで機能のリクエスト、提案、バグ追跡にのみ使用されるべきです 27 | - わからないことやトラブルシューティングは、[GitHub Discussions](https://github.com/1673beta/notectl/discussions)に作成するか、[リポジトリ所有者](https://c.koliosky.com/@esurio1673)に質問しにきてください。 28 | 29 | > [!WARNING] 30 | > 解決されようとしているIssueは、解決策がマージされるまで閉じないでください。 31 | 32 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "notectl" 3 | version = "0.2.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anstyle = "1.0.10" 8 | base64 = "0.22.1" 9 | chrono = { version = "0.4.38", features = ["serde"] } 10 | clap = { version = "4.5.22", features = ["derive", "env"] } 11 | futures = "0.3.31" 12 | lazy_static = "1.5.0" 13 | log = "0.4.22" 14 | meilisearch-sdk = "0.28.0" 15 | nanoid = "0.4.0" 16 | openssl = "0.10.70" 17 | rand = { version = "0.8.5", features = ["serde"] } 18 | redis = { version = "0.27.6", features = ["tokio-rustls-comp", "cluster", "json", "r2d2"] } 19 | regex = "1.11.1" 20 | sea-orm = { version = "1.1.6", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros", "debug-print"] } 21 | serde = { version = "1.0.215", features = ["derive", "serde_derive"] } 22 | serde_json = "1.0.133" 23 | serde_yml = "0.0.12" 24 | syntect = "5.2.0" 25 | thiserror = "2.0.11" 26 | tokio = { version = "1.43.0", features = ["full"] } 27 | tracing = "0.1.41" 28 | tracing-subscriber = "0.3.19" 29 | ulid = "1.1.3" 30 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:latest AS builder 2 | 3 | WORKDIR /app 4 | COPY ./ /app 5 | RUN cargo build --release 6 | 7 | FROM gcr.io/distroless/cc-debian12 8 | 9 | COPY --from=builder /app/target/release/notectl . 10 | ENTRYPOINT [ "./notectl" ] -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Esurio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifneq (,$(wildcard ./.env)) 2 | include .env 3 | export 4 | endif 5 | 6 | SRC := Cargo.toml 7 | 8 | .PHONY: generate-entities-mac 9 | generate-entities: 10 | rm -rf src/entities 11 | sea-orm-cli generate entity \ 12 | --output-dir='src/entities' \ 13 | --database-url='postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)' \ 14 | --date-time-crate='chrono' \ 15 | --with-serde='both' \ 16 | --with-prelude='all-allow-unused-imports' && \ 17 | gsed -i '3i use clap::ValueEnum;' src/entities/sea_orm_active_enums.rs && \ 18 | gsed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)\]/#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum)]/g' src/entities/sea_orm_active_enums.rs && \ 19 | cargo fmt 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # notectl 2 | 3 | [notectl](https://github.com/1673beta/notectl.git) is an unofficial CLI tool for managing Misskey v13 or later. 4 | This tool is useful to maintainance your instances, deleting older notes, and deploy index to meilisearch. 5 | 6 | ## Install 7 | See [Docs/Install](docs/install.md). 8 | 9 | ## Usage 10 | See [Docs/Feature](docs/feature.md). -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1673beta/notectl/003413f6fe2f8d75915b8772f2133c6a69502b1b/TODO.md -------------------------------------------------------------------------------- /compose.local.yml: -------------------------------------------------------------------------------- 1 | services: 2 | misskey: 3 | image: misskey/misskey:latest 4 | ports: 5 | - "3030:3030" 6 | depends_on: 7 | - db 8 | - redis 9 | networks: 10 | - internal_network 11 | - external_network 12 | volumes: 13 | - ./.config/:/misskey/.config 14 | - ./files:/misskey/files 15 | 16 | db: 17 | image: postgres:15-alpine 18 | ports: 19 | - "5432:5432" 20 | networks: 21 | - internal_network 22 | - external_network 23 | environment: 24 | POSTGRES_DB: misskey 25 | POSTGRES_USER: postgres 26 | POSTGRES_PASSWORD: postgres 27 | volumes: 28 | - ./db:/var/lib/postgresql/data 29 | 30 | redis: 31 | image: redis:7-alpine 32 | ports: 33 | - "6379:6379" 34 | networks: 35 | - internal_network 36 | - external_network 37 | volumes: 38 | - ./redis:/data 39 | 40 | meilisearch: 41 | image: getmeili/meilisearch:latest 42 | ports: 43 | - "7700:7700" 44 | networks: 45 | - internal_network 46 | - external_network 47 | volumes: 48 | - ./meilisearch:/data.ms 49 | environment: 50 | - MEILI_NO_ANALYTICS=true 51 | - MEILI_MASTER_KEY=5acc97a208a444a84413f73e5bf40db153860082 52 | - MEILI_ENV=development 53 | 54 | networks: 55 | internal_network: 56 | internal: true 57 | external_network: 58 | 59 | volumes: 60 | db: 61 | redis: 62 | meilisearch: -------------------------------------------------------------------------------- /docs/feature.md: -------------------------------------------------------------------------------- 1 | # 実装されている機能 2 | 3 | ## はじめに 4 | `webpush`および`id`以外のコマンドは全て`--config`あるいは`-c`フラグで`.config/default.yml`が存在するパスを指定してください。 5 | 6 | ## Search CLI 7 | ```bash 8 | notectl search deploy --config 9 | ``` 10 | Meilisearchに対してインデックスを生成します。既にMeilisearchのインデックスが存在する場合、後述の`drop`コマンドを使用してから実行してください。 11 | 12 | ```bash 13 | notectl search drop --config 14 | ``` 15 | Meilisearchのインデックスを削除します。 16 | 17 | ```bash 18 | notectl search list 19 | ``` 20 | 現在存在するMeilisearchのインデックスの一覧を取得します。 21 | 22 | ```bash 23 | notectl search health 24 | ``` 25 | Meilisearchのヘルスチェックを行います。 26 | 27 | ## Webpush CLI 28 | ```bash 29 | notectl webpush generate 30 | ``` 31 | プッシュ通知機能を有効にするのに必要な公開鍵と秘密鍵を生成します。 32 | 33 | ## Config CLI 34 | ```bash 35 | notectl config show --config 36 | ``` 37 | `.config/default.yml`の記述をjson形式で出力します。 38 | 39 | ## Remote CLI 40 | ```bash 41 | notectl remote gone --config --url 42 | ``` 43 | `--url`フラグで指定したリモートサーバーを410 Goneで閉鎖したと指定します。INSTANCE_URLには`https://` の部分はつけないでください。 44 | 45 | ```bash 46 | notectl remote suspend --config --url 47 | ``` 48 | `--url`フラグで指定したリモートサーバーに対して配信停止します。既に410を出して停止している、あるいは既に配信停止になっているサーバーについてはエラーが出力されます。 49 | 50 | ```bash 51 | notectl remote unsuspend --config --url 52 | ``` 53 | `--url`フラグで指定したリモートサーバーに対して実施している配信停止を解除します。 54 | 55 | ## Id CLI 56 | ```bash 57 | notectl id parse --format --id 58 | ``` 59 | 指定された形式のidから日時を取得します。 60 | ```bash 61 | notectl id gen --format 62 | ``` 63 | 指定された形式で、現在日時からIDを生成します。 64 | 65 | ## Note CLI 66 | ```bash 67 | notectl note delete --config --days [--host: ] 68 | ``` 69 | 指定した日数以前のノートを削除します。 70 | 日数には1〜18446744073709551615までが指定できます。 71 | `--host`フラグを使用することで、特定のホストの指定した日数以前のノートを消すことも可能です。このフラグを使用しない場合、デフォルトではリモートの全ての投稿が対象となります。 72 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # インストール 2 | 3 | ## systemd環境でのインストール 4 | 5 | #### 前提条件 6 | - [ ] Rust v1.76.0以降が入っていること 7 | 8 | #### やり方 9 | ```bash 10 | git clone https://github.com/1673beta/notectl.git 11 | cd notectl 12 | cargo install --path . 13 | ``` 14 | 15 | ## docker環境での使用 16 | 17 | ### ローカルでイメージをビルドする場合 18 | #### 前提条件 19 | - [ ] Docker Composeがインストールされていること 20 | - [ ] CPUが強靭であること(参考: M2のMacbook Airでは250秒から320秒程度かかります) 21 | 22 | #### ビルド 23 | ```bash 24 | git clone https://github.com/1673beta/notectl.git 25 | 26 | cd notectl 27 | docker compose build 28 | ``` 29 | 30 | ### イメージをpullする場合 31 | ```bash 32 | docker pull ghcr.io/1673beta/1673beta/notectl:latest 33 | ``` 34 | 35 | #### compose.ymlの編集 36 | **Misskey側の**compose.ymlを開いて、下記項目を追加します。 37 | ```yml 38 | notectl: 39 | image: ghcr.io/1673beta/1673beta/notectl:latest 40 | networks: 41 | - internal_network 42 | - external_network 43 | volumes: 44 | - ./files:/files 45 | - ./.config:/.config:ro 46 | ``` 47 | 48 | #### 実行 49 | ```bash 50 | sudo docker compose run --rm notectl 51 | ``` 52 | サブコマンドはhelpを実行するか、[feature](./feature.md)を見てください。 53 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | tab_spaces = 2 -------------------------------------------------------------------------------- /src/cli/command.rs: -------------------------------------------------------------------------------- 1 | use crate::cli::config::show::ConfigCommand; 2 | use crate::cli::vapid::WebpushCommand; 3 | use clap::{ColorChoice, Parser, Subcommand}; 4 | 5 | use crate::cli::id::IdCommand; 6 | use crate::cli::note::NoteCommand; 7 | use crate::cli::remote::RemoteCommand; 8 | use crate::cli::search::SearchCommand; 9 | use crate::cli::user::UserCommand; 10 | 11 | #[derive(Debug, Parser)] 12 | #[command(name = "notectl", about = "A CLI tool for managing misskey", color = ColorChoice::Always, styles = super::style::style())] 13 | pub struct Cli { 14 | #[clap(subcommand)] 15 | pub cmd: Commands, 16 | } 17 | 18 | #[derive(Debug, Subcommand)] 19 | pub enum Commands { 20 | #[command(about = "About webpush notification")] 21 | Webpush(WebpushCommand), 22 | #[command(about = "About your misskey configuration")] 23 | Config(ConfigCommand), 24 | #[command(about = "About Meilisearch")] 25 | Search(SearchCommand), 26 | #[command(about = "About remote server")] 27 | Remote(RemoteCommand), 28 | #[command(about = "About id")] 29 | Id(IdCommand), 30 | #[command(about = "About user")] 31 | User(UserCommand), 32 | #[command(about = "About note")] 33 | Note(NoteCommand), 34 | } 35 | 36 | pub async fn exec() -> Result<(), Box> { 37 | let args = Cli::parse(); 38 | match args.cmd { 39 | Commands::Webpush(cmd) => { 40 | if let Err(e) = cmd.exec() { 41 | eprintln!("{}", e); 42 | } 43 | } 44 | Commands::Config(cmd) => { 45 | if let Err(e) = cmd.exec() { 46 | eprintln!("{}", e); 47 | } 48 | } 49 | Commands::Search(cmd) => { 50 | if let Err(e) = cmd.exec().await { 51 | eprintln!("{}", e); 52 | } 53 | } 54 | Commands::Remote(cmd) => { 55 | if let Err(e) = cmd.exec().await { 56 | eprintln!("{}", e); 57 | } 58 | } 59 | Commands::Id(cmd) => { 60 | cmd.exec(); 61 | } 62 | Commands::User(cmd) => { 63 | if let Err(e) = cmd.exec().await { 64 | eprintln!("{}", e); 65 | } 66 | } 67 | Commands::Note(cmd) => { 68 | if let Err(e) = cmd.exec().await { 69 | eprintln!("{}", e); 70 | } 71 | } 72 | } 73 | Ok(()) 74 | } 75 | -------------------------------------------------------------------------------- /src/cli/config/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod show; 2 | -------------------------------------------------------------------------------- /src/cli/config/show.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{load_config, print_config, MisskeyConfig}; 2 | use clap::{Parser, Subcommand}; 3 | 4 | #[derive(Debug, Parser)] 5 | #[command(name = "config")] 6 | pub struct ConfigCommand { 7 | #[command(subcommand)] 8 | pub subcmd: ConfigSubCommand, 9 | } 10 | 11 | #[derive(Debug, Subcommand)] 12 | pub enum ConfigSubCommand { 13 | Show { 14 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 15 | config_path: String, 16 | }, 17 | } 18 | 19 | impl ConfigCommand { 20 | pub fn exec(&self) -> Result<(), Box> { 21 | match &self.subcmd { 22 | ConfigSubCommand::Show { config_path } => { 23 | let config: MisskeyConfig = load_config(config_path)?; 24 | let _ = print_config(&config); 25 | } 26 | } 27 | Ok(()) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/cli/id/gen.rs: -------------------------------------------------------------------------------- 1 | use crate::util; 2 | 3 | use super::IdType; 4 | use std::time::{SystemTime, UNIX_EPOCH}; 5 | 6 | pub fn gen(format: IdType) -> String { 7 | let time = SystemTime::now() 8 | .duration_since(UNIX_EPOCH) 9 | .unwrap() 10 | .as_millis() as u64; 11 | match format { 12 | IdType::Aid => { 13 | let id = util::id::aid::gen_aid(time).unwrap(); 14 | format!("generated aid: {}", id) 15 | } 16 | IdType::Aidx => { 17 | let id = util::id::aidx::gen_aidx(time).unwrap(); 18 | format!("generated aidx: {}", id) 19 | } 20 | IdType::Meid => { 21 | let id = util::id::meid::gen_meid(time); 22 | format!("generated meid: {}", id) 23 | } 24 | IdType::ObjectId => { 25 | let id = util::id::objectid::gen_object_id(time); 26 | format!("generated objectid: {}", id) 27 | } 28 | IdType::Ulid => { 29 | let id = util::id::ulid::gen_ulid(time); 30 | format!("generated ulid: {}", id) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/cli/id/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gen; 2 | pub mod parse; 3 | 4 | use clap::{Parser, Subcommand, ValueEnum}; 5 | use gen::gen; 6 | use parse::parse; 7 | 8 | #[derive(Debug, Parser)] 9 | #[command(name = "id")] 10 | pub struct IdCommand { 11 | #[command(subcommand)] 12 | pub subcmd: IdSubCommand, 13 | } 14 | 15 | #[derive(Debug, Clone, ValueEnum, Copy)] 16 | pub enum IdType { 17 | Aid, 18 | Aidx, 19 | Meid, 20 | ObjectId, 21 | Ulid, 22 | } 23 | 24 | #[derive(Debug, Subcommand)] 25 | pub enum IdSubCommand { 26 | Parse { 27 | #[arg(short = 'f', long = "format")] 28 | id_type: String, 29 | #[arg(short = 'i', long = "id")] 30 | id: String, 31 | }, 32 | Gen { 33 | #[arg(short = 'f', long = "format")] 34 | id_type: IdType, 35 | }, 36 | } 37 | 38 | impl IdCommand { 39 | pub fn exec(&self) { 40 | match &self.subcmd { 41 | IdSubCommand::Parse { id_type, id } => { 42 | println!("{}", parse(id, id_type)) 43 | } 44 | IdSubCommand::Gen { id_type } => { 45 | println!("{}", gen(*id_type)) 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/cli/id/parse.rs: -------------------------------------------------------------------------------- 1 | use crate::util::id::{aid, aidx, meid, objectid, ulid}; 2 | 3 | pub fn parse(id: &str, id_type: &str) -> String { 4 | match id_type { 5 | "aid" => aid::formatted_time(id), 6 | "aidx" => aidx::formatted_time(id), 7 | "meid" => meid::parse_meid_with_format(id).to_string(), 8 | "objectid" => objectid::parse_object_id_with_format(id).to_string(), 9 | "ulid" => ulid::formatted_time(id), 10 | _ => "Unknown or Unsupported ID type".to_string(), 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/cli/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod command; 2 | pub mod config; 3 | pub mod id; 4 | pub mod note; 5 | pub mod remote; 6 | pub mod search; 7 | pub mod style; 8 | pub mod user; 9 | pub mod vapid; 10 | -------------------------------------------------------------------------------- /src/cli/note/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod delete; 2 | 3 | use crate::entities::sea_orm_active_enums::NoteVisibilityEnum; 4 | use clap::{Parser, Subcommand}; 5 | use delete::delete; 6 | 7 | #[derive(Debug, Parser)] 8 | #[command(name = "note")] 9 | pub struct NoteCommand { 10 | #[command(subcommand)] 11 | pub subcmd: NoteSubCommand, 12 | } 13 | 14 | #[derive(Debug, Subcommand)] 15 | pub enum NoteSubCommand { 16 | #[command(about = "Delete notes from remote server. Needs to specify days before to delete.")] 17 | Delete { 18 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 19 | config_path: String, 20 | #[arg(short = 'H', long = "host")] 21 | host: Option, 22 | #[arg(short = 'd', long = "days")] 23 | days: u64, 24 | #[arg(short = 'v', long = "visibility", value_delimiter = ',')] 25 | visibility: Option>, 26 | #[arg(long = "no-interaction", conflicts_with_all = ["no_reaction", "no_reply", "no_renote", "no_clipped"], action = clap::ArgAction::SetTrue)] 27 | no_interaction: bool, 28 | #[arg(long = "no-reaction", action = clap::ArgAction::SetTrue, conflicts_with = "no_interaction")] 29 | no_reaction: bool, 30 | #[arg(long = "no-reply", action = clap::ArgAction::SetTrue, conflicts_with = "no_interaction")] 31 | no_reply: bool, 32 | #[arg(long = "no-renote", action = clap::ArgAction::SetTrue, conflicts_with = "no_interaction")] 33 | no_renote: bool, 34 | #[arg(long = "no-clipped", action = clap::ArgAction::SetTrue, conflicts_with = "no_interaction")] 35 | no_clipped: bool, 36 | }, 37 | } 38 | 39 | impl NoteCommand { 40 | pub async fn exec(&self) -> Result<(), Box> { 41 | match &self.subcmd { 42 | NoteSubCommand::Delete { 43 | config_path, 44 | host, 45 | days, 46 | visibility, 47 | no_interaction, 48 | no_reaction, 49 | no_reply, 50 | no_renote, 51 | no_clipped, 52 | } => { 53 | let no_reaction_input = *no_interaction || *no_reaction; 54 | let no_reply_input = *no_interaction || *no_reply; 55 | let no_renote_input = *no_interaction || *no_renote; 56 | let no_clipped_input = *no_interaction || *no_clipped; 57 | delete( 58 | config_path, 59 | host.as_deref(), 60 | *days, 61 | visibility.clone(), 62 | no_reaction_input, 63 | no_reply_input, 64 | no_renote_input, 65 | no_clipped_input, 66 | ) 67 | .await?; 68 | } 69 | } 70 | Ok(()) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/cli/remote/gone.rs: -------------------------------------------------------------------------------- 1 | use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set}; 2 | 3 | use crate::{ 4 | db::postgres::connect_pg, 5 | entities::{instance, prelude::*}, 6 | }; 7 | 8 | pub async fn gone(config_path: &str, url: &str) -> Result<(), Box> { 9 | let pg_client = connect_pg(config_path).await.unwrap(); 10 | 11 | let host = Instance::find() 12 | .filter(instance::Column::Host.eq(url)) 13 | .one(&pg_client) 14 | .await 15 | .unwrap(); 16 | if host.is_none() { 17 | println!("Host not found"); 18 | return Err("Host not found".into()); 19 | } 20 | let mut host: instance::ActiveModel = host.unwrap().into(); 21 | host.suspension_state = 22 | Set(crate::entities::sea_orm_active_enums::InstanceSuspensionstateEnum::GoneSuspended); 23 | host.is_not_responding = Set(true); 24 | host.update(&pg_client).await?; 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /src/cli/remote/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gone; 2 | pub mod suspend; 3 | pub mod unsuspend; 4 | 5 | // Note: サーバーのサスペンド状態は、 6 | // none | manuallySuspended | goneSuspended | autoSuspendedForNotResponding 7 | // の4つ 8 | 9 | use clap::{Parser, Subcommand}; 10 | use gone::gone; 11 | use suspend::suspend; 12 | use unsuspend::unsuspend; 13 | 14 | #[derive(Debug, Parser)] 15 | #[command(name = "remote")] 16 | pub struct RemoteCommand { 17 | #[command(subcommand)] 18 | pub subcmd: RemoteSubCommand, 19 | } 20 | 21 | #[derive(Debug, Subcommand)] 22 | pub enum RemoteSubCommand { 23 | Gone { 24 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 25 | config_path: String, 26 | #[arg(short = 'u', long = "url")] 27 | url: String, 28 | }, 29 | Suspend { 30 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 31 | config_path: String, 32 | #[arg(short = 'u', long = "url")] 33 | url: String, 34 | }, 35 | Unsuspend { 36 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 37 | config_path: String, 38 | #[arg(short = 'u', long = "url")] 39 | url: String, 40 | }, 41 | } 42 | 43 | impl RemoteCommand { 44 | pub async fn exec(&self) -> Result<(), Box> { 45 | match &self.subcmd { 46 | RemoteSubCommand::Gone { config_path, url } => { 47 | gone(config_path, url).await?; 48 | } 49 | RemoteSubCommand::Suspend { config_path, url } => { 50 | suspend(config_path, url).await?; 51 | } 52 | RemoteSubCommand::Unsuspend { config_path, url } => { 53 | unsuspend(config_path, url).await?; 54 | } 55 | } 56 | Ok(()) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/cli/remote/suspend.rs: -------------------------------------------------------------------------------- 1 | use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set}; 2 | 3 | use crate::db::postgres::connect_pg; 4 | use crate::entities::{instance, prelude::*, sea_orm_active_enums}; 5 | 6 | pub async fn suspend(config_path: &str, url: &str) -> Result<(), Box> { 7 | let pg_client = connect_pg(config_path).await.unwrap(); 8 | 9 | let host = Instance::find() 10 | .filter(instance::Column::Host.eq(url)) 11 | .one(&pg_client) 12 | .await 13 | .unwrap(); 14 | if host.is_none() { 15 | println!("Host not found"); 16 | return Err("Host not found".into()); 17 | } 18 | 19 | let suspension_state = host.clone().unwrap().suspension_state; 20 | if suspension_state == sea_orm_active_enums::InstanceSuspensionstateEnum::GoneSuspended { 21 | return Err("Host is already gone".into()); 22 | } else if suspension_state == sea_orm_active_enums::InstanceSuspensionstateEnum::ManuallySuspended 23 | { 24 | return Err("Host is already suspended".into()); 25 | } 26 | 27 | let mut host: instance::ActiveModel = host.unwrap().into(); 28 | tokio::spawn(async move { 29 | host.suspension_state = 30 | Set(sea_orm_active_enums::InstanceSuspensionstateEnum::ManuallySuspended); 31 | host.is_not_responding = Set(true); 32 | host.update(&pg_client).await.unwrap(); 33 | }) 34 | .await 35 | .unwrap(); 36 | Ok(()) 37 | } 38 | -------------------------------------------------------------------------------- /src/cli/remote/unsuspend.rs: -------------------------------------------------------------------------------- 1 | use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set}; 2 | 3 | use crate::db::postgres::connect_pg; 4 | use crate::entities::{instance, prelude::*, sea_orm_active_enums}; 5 | 6 | pub async fn unsuspend(config_path: &str, url: &str) -> Result<(), Box> { 7 | let pg_client = connect_pg(config_path).await.unwrap(); 8 | 9 | let host = Instance::find() 10 | .filter(instance::Column::Host.eq(url)) 11 | .one(&pg_client) 12 | .await 13 | .unwrap(); 14 | if host.is_none() { 15 | println!("Host not found"); 16 | return Err("Host not found".into()); 17 | } 18 | let mut host: instance::ActiveModel = host.unwrap().into(); 19 | host.suspension_state = Set(sea_orm_active_enums::InstanceSuspensionstateEnum::None); 20 | host.is_not_responding = Set(false); 21 | host.update(&pg_client).await?; 22 | Ok(()) 23 | } 24 | -------------------------------------------------------------------------------- /src/cli/search/deploy.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{IdMethod, MeilisearchScope}; 2 | use crate::entities::prelude::*; 3 | use meilisearch_sdk::client::*; 4 | use meilisearch_sdk::settings::{PaginationSetting, Settings, TypoToleranceSettings}; 5 | use sea_orm::{ColumnTrait, EntityTrait, QueryFilter}; 6 | 7 | use crate::util::id::{aid, aidx, meid, objectid, ulid}; 8 | use crate::{config::load_config, consts::MeiliNotes, db::postgres::connect_pg, entities::note}; 9 | 10 | pub async fn deploy(config_path: &str) -> Result<(), Box> { 11 | let config = load_config(config_path).unwrap(); 12 | let meili_config = config.meilisearch.clone().unwrap(); 13 | let host = meili_config.host; 14 | let port = meili_config.port; 15 | let ssl = meili_config.ssl; 16 | let api_key = meili_config.api_key; 17 | let index = meili_config.index; 18 | let scope = meili_config.scope.unwrap(); 19 | 20 | let pg_client = connect_pg(config_path).await.unwrap(); 21 | 22 | let notes: Vec = match scope { 23 | MeilisearchScope::Local => { 24 | Note::find() 25 | .filter(note::Column::UserHost.is_null()) 26 | .filter( 27 | note::Column::Visibility 28 | .eq("public") 29 | .or(note::Column::Visibility.eq("home")), 30 | ) 31 | .all(&pg_client) 32 | .await? 33 | } 34 | MeilisearchScope::Global => Note::find().all(&pg_client).await?, 35 | MeilisearchScope::Custom(hosts) => { 36 | let host = hosts.concat(); 37 | Note::find() 38 | .filter( 39 | note::Column::UserHost 40 | .contains(host) 41 | .or(note::Column::UserHost.is_null()), 42 | ) 43 | .all(&pg_client) 44 | .await? 45 | } 46 | }; 47 | 48 | let indexes: Vec = match config.id { 49 | IdMethod::Aid => notes 50 | .iter() 51 | .map(|note| MeiliNotes { 52 | id: note.id.clone(), 53 | created_at: aid::parse(¬e.id).unwrap(), 54 | user_id: note.user_id.clone(), 55 | user_host: note.user_host.clone(), 56 | channel_id: note.channel_id.clone(), 57 | cw: note.cw.clone(), 58 | text: note.text.clone(), 59 | tags: note.tags.clone(), 60 | }) 61 | .collect(), 62 | IdMethod::Aidx => notes 63 | .iter() 64 | .map(|note| MeiliNotes { 65 | id: note.id.clone(), 66 | created_at: aidx::parse(¬e.id).unwrap(), 67 | user_id: note.user_id.clone(), 68 | user_host: note.user_host.clone(), 69 | channel_id: note.channel_id.clone(), 70 | cw: note.cw.clone(), 71 | text: note.text.clone(), 72 | tags: note.tags.clone(), 73 | }) 74 | .collect(), 75 | IdMethod::Ulid => notes 76 | .iter() 77 | .map(|note| MeiliNotes { 78 | id: note.id.clone(), 79 | created_at: ulid::parse(¬e.id).unwrap(), 80 | user_id: note.user_id.clone(), 81 | user_host: note.user_host.clone(), 82 | channel_id: note.channel_id.clone(), 83 | cw: note.cw.clone(), 84 | text: note.text.clone(), 85 | tags: note.tags.clone(), 86 | }) 87 | .collect(), 88 | IdMethod::Meid => notes 89 | .iter() 90 | .map(|note| MeiliNotes { 91 | id: note.id.clone(), 92 | created_at: meid::parse_meid(¬e.id).unwrap(), 93 | user_id: note.user_id.clone(), 94 | user_host: note.user_host.clone(), 95 | channel_id: note.channel_id.clone(), 96 | cw: note.cw.clone(), 97 | text: note.text.clone(), 98 | tags: note.tags.clone(), 99 | }) 100 | .collect(), 101 | IdMethod::ObjectId => notes 102 | .iter() 103 | .map(|note| MeiliNotes { 104 | id: note.id.clone(), 105 | created_at: objectid::parse_object_id(¬e.id).unwrap(), 106 | user_id: note.user_id.clone(), 107 | user_host: note.user_host.clone(), 108 | channel_id: note.channel_id.clone(), 109 | cw: note.cw.clone(), 110 | text: note.text.clone(), 111 | tags: note.tags.clone(), 112 | }) 113 | .collect(), 114 | }; 115 | 116 | let host_url = format!("{}://{}:{}", if ssl { "https" } else { "http" }, host, port); 117 | let uid = format!("{}---notes", index); 118 | let client = Client::new(host_url, Some(api_key)).unwrap(); 119 | 120 | let typotolerance = TypoToleranceSettings { 121 | enabled: Some(true), 122 | disable_on_attributes: None, 123 | disable_on_words: None, 124 | min_word_size_for_typos: None, 125 | }; 126 | 127 | let pagination = PaginationSetting { 128 | max_total_hits: 10000, 129 | }; 130 | 131 | let setting = Settings::new() 132 | .with_searchable_attributes(vec!["text", "cw"]) 133 | .with_sortable_attributes(vec!["createdAt"]) 134 | .with_filterable_attributes(vec!["createdAt", "userId", "userHost", "channelId", "tags"]) 135 | .with_typo_tolerance(typotolerance) 136 | .with_pagination(pagination); 137 | 138 | let meili_index = client.index(uid.clone()); 139 | // TODO: ここをtokio::spawnで並列処理にする 140 | let task_set = meili_index.set_settings(&setting).await.unwrap(); 141 | let queue_set = client.wait_for_task(task_set, None, None).await.unwrap(); 142 | let task_doc = meili_index 143 | .add_documents(&indexes, Some("id")) 144 | .await 145 | .unwrap(); 146 | let queue_doc = client.wait_for_task(task_doc, None, None).await.unwrap(); 147 | 148 | if queue_set.is_success() && queue_doc.is_success() { 149 | println!("Deployed index: {}", uid); 150 | } else { 151 | println!("Failed to deploy index"); 152 | } 153 | 154 | Ok(()) 155 | } 156 | -------------------------------------------------------------------------------- /src/cli/search/drop.rs: -------------------------------------------------------------------------------- 1 | use meilisearch_sdk::client::*; 2 | 3 | use crate::config::load_config; 4 | 5 | pub async fn drop(config_path: &str) -> Result<(), Box> { 6 | let config = load_config(config_path).unwrap(); 7 | let meili_config = config.meilisearch.clone().unwrap(); 8 | let host = meili_config.host; 9 | let port = meili_config.port; 10 | let ssl = meili_config.ssl; 11 | let api_key = meili_config.api_key; 12 | let index = meili_config.index; 13 | 14 | let host_url = format!("{}://{}:{}", if ssl { "https" } else { "http" }, host, port); 15 | let uid = format!("{}---notes", index); 16 | let client = Client::new(host_url, Some(api_key)).unwrap(); 17 | let task = client.delete_index(uid).await.unwrap(); 18 | println!("Dropped index: {}", task.status); 19 | 20 | Ok(()) 21 | } 22 | -------------------------------------------------------------------------------- /src/cli/search/get.rs: -------------------------------------------------------------------------------- 1 | // TODO 2 | -------------------------------------------------------------------------------- /src/cli/search/health.rs: -------------------------------------------------------------------------------- 1 | use meilisearch_sdk::client::*; 2 | 3 | use crate::config::load_config; 4 | 5 | pub async fn health(config_path: &str) -> Result<(), Box> { 6 | let config = load_config(config_path).unwrap(); 7 | let meili_config = config.meilisearch.clone().unwrap(); 8 | let host = meili_config.host; 9 | let port = meili_config.port; 10 | let ssl = meili_config.ssl; 11 | let api_key = meili_config.api_key; 12 | 13 | let host_url = format!("{}://{}:{}", if ssl { "https" } else { "http" }, host, port); 14 | let client = Client::new(host_url, Some(api_key)).unwrap(); 15 | let is_healthy = client.is_healthy().await; 16 | let health = client.health().await.unwrap().status.to_string(); 17 | 18 | println!("Is Meilisearch Healthy?: {}", is_healthy); 19 | println!("Health Status: {}", health); 20 | 21 | Ok(()) 22 | } 23 | -------------------------------------------------------------------------------- /src/cli/search/list.rs: -------------------------------------------------------------------------------- 1 | use meilisearch_sdk::client::*; 2 | use syntect::easy::HighlightLines; 3 | use syntect::highlighting::{Style, ThemeSet}; 4 | use syntect::parsing::SyntaxSet; 5 | use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; 6 | 7 | use crate::config::load_config; 8 | 9 | pub async fn list(config_path: &str) -> Result<(), Box> { 10 | let config = load_config(config_path).unwrap(); 11 | let meili_config = config.meilisearch.clone().unwrap(); 12 | let host = meili_config.host; 13 | let port = meili_config.port; 14 | let ssl = meili_config.ssl; 15 | let api_key = meili_config.api_key; 16 | 17 | let host_url: String = format!("{}://{}:{}", if ssl { "https" } else { "http" }, host, port); 18 | let client: Client = Client::new(host_url, Some(api_key)).unwrap(); 19 | let index = client.list_all_indexes_raw().await.unwrap(); 20 | let json = serde_json::to_string_pretty(&index).unwrap(); 21 | 22 | let ps = SyntaxSet::load_defaults_newlines(); 23 | let ts = ThemeSet::load_defaults(); 24 | 25 | let syntax = ps.find_syntax_by_extension("json").unwrap(); 26 | let mut h = HighlightLines::new(syntax, &ts.themes["base16-ocean.dark"]); 27 | for line in LinesWithEndings::from(&json) { 28 | let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ps).unwrap(); 29 | let escaped = as_24_bit_terminal_escaped(&ranges[..], true); 30 | print!("{}", escaped); 31 | } 32 | Ok(()) 33 | } 34 | -------------------------------------------------------------------------------- /src/cli/search/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod deploy; 2 | pub mod drop; 3 | pub mod get; 4 | pub mod health; 5 | pub mod list; 6 | pub mod redeploy; 7 | 8 | use clap::{Parser, Subcommand}; 9 | use deploy::deploy; 10 | use drop::drop; 11 | use health::health; 12 | use list::list; 13 | 14 | #[derive(Debug, Parser)] 15 | #[command(name = "search")] 16 | pub struct SearchCommand { 17 | #[command(subcommand)] 18 | pub subcmd: SearchSubCommand, 19 | } 20 | 21 | #[derive(Debug, Subcommand)] 22 | pub enum SearchSubCommand { 23 | List { 24 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 25 | config_path: String, 26 | }, 27 | Health { 28 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 29 | config_path: String, 30 | }, 31 | Drop { 32 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 33 | config_path: String, 34 | }, 35 | Deploy { 36 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 37 | config_path: String, 38 | }, 39 | } 40 | 41 | impl SearchCommand { 42 | pub async fn exec(&self) -> Result<(), Box> { 43 | match &self.subcmd { 44 | SearchSubCommand::List { config_path } => { 45 | list(config_path).await?; 46 | } 47 | SearchSubCommand::Health { config_path } => { 48 | health(config_path).await?; 49 | } 50 | SearchSubCommand::Drop { config_path } => { 51 | drop(config_path).await?; 52 | } 53 | SearchSubCommand::Deploy { config_path } => { 54 | deploy(config_path).await?; 55 | } 56 | } 57 | Ok(()) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/cli/search/redeploy.rs: -------------------------------------------------------------------------------- 1 | // TODO 2 | -------------------------------------------------------------------------------- /src/cli/style.rs: -------------------------------------------------------------------------------- 1 | use anstyle::AnsiColor; 2 | use anstyle::Effects; 3 | 4 | pub fn style() -> clap::builder::Styles { 5 | clap::builder::Styles::styled() 6 | .header(AnsiColor::Green.on_default().effects(Effects::BOLD)) 7 | .usage(AnsiColor::Green.on_default().effects(Effects::BOLD)) 8 | .error( 9 | AnsiColor::Red 10 | .on_default() 11 | .effects(Effects::BOLD) 12 | .effects(Effects::DOUBLE_UNDERLINE), 13 | ) 14 | .literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD)) 15 | .placeholder( 16 | AnsiColor::White 17 | .on_default() 18 | .effects(Effects::DOUBLE_UNDERLINE), 19 | ) 20 | .valid(AnsiColor::Green.on_default().effects(Effects::BOLD)) 21 | .invalid(AnsiColor::Red.on_default().effects(Effects::BOLD)) 22 | } 23 | -------------------------------------------------------------------------------- /src/cli/user/cull.rs: -------------------------------------------------------------------------------- 1 | // 閉鎖などで存在しなくなったリモートアカウントを削除する 2 | use sea_orm::{ColumnTrait, EntityTrait, ModelTrait, QueryFilter, QuerySelect, TransactionTrait}; 3 | 4 | use crate::db::postgres::connect_pg; 5 | use crate::entities::sea_orm_active_enums::InstanceSuspensionstateEnum; 6 | use crate::entities::{instance, prelude::*, user}; 7 | 8 | pub async fn cull(config_path: &str) -> Result<(), Box> { 9 | let pg_client = connect_pg(config_path).await?; 10 | let txn = pg_client.begin().await?; 11 | // need to output logs 12 | tracing_subscriber::fmt() 13 | .with_max_level(tracing::Level::INFO) 14 | .init(); 15 | 16 | let gone_hosts = Instance::find() 17 | .select_only() 18 | .filter(instance::Column::SuspensionState.eq(InstanceSuspensionstateEnum::GoneSuspended)) 19 | .all(&pg_client) 20 | .await?; 21 | 22 | let host_name: Vec = gone_hosts.iter().map(|i| i.host.clone()).collect(); 23 | 24 | let accounts = User::find() 25 | .filter(user::Column::Host.is_in(host_name)) 26 | .all(&pg_client) 27 | .await?; 28 | 29 | for account in accounts { 30 | account.delete(&txn).await?; 31 | } 32 | txn.commit().await?; 33 | Ok(()) 34 | } 35 | -------------------------------------------------------------------------------- /src/cli/user/delete.rs: -------------------------------------------------------------------------------- 1 | // アカウントをID指定で削除する 2 | 3 | use sea_orm::{ColumnTrait, Condition, EntityTrait, ModelTrait, QueryFilter, TransactionTrait}; 4 | 5 | use crate::consts::UserIdentifier; 6 | use crate::db::postgres::connect_pg; 7 | use crate::entities::{prelude::*, user}; 8 | 9 | pub async fn delete( 10 | config_path: &str, 11 | id: Option>, 12 | user: Option>, 13 | ) -> Result<(), Box> { 14 | let pg_client = connect_pg(config_path).await?; 15 | let txn = pg_client.begin().await?; 16 | // need to output logs 17 | tracing_subscriber::fmt() 18 | .with_max_level(tracing::Level::INFO) 19 | .init(); 20 | 21 | if id.is_none() && user.is_none() { 22 | tracing::error!("Either username or id is required."); 23 | std::process::exit(1); 24 | } 25 | 26 | let mut query = User::find(); 27 | 28 | if let Some(users) = user { 29 | for user in users { 30 | query = query.filter( 31 | Condition::all() 32 | .add(user::Column::Username.contains(user.username)) 33 | .add(user::Column::Host.contains(user.host)), 34 | ) 35 | } 36 | } 37 | 38 | if let Some(id) = id { 39 | let user_id = id.iter().map(|i| i.to_string()).collect::>(); 40 | query = query.filter(user::Column::Id.is_in(user_id)); 41 | } 42 | 43 | let accounts = query.all(&txn).await?; 44 | 45 | for account in accounts { 46 | if account.host.is_none() { 47 | return Err("This account is not remote account.".into()); 48 | } else if account.is_root { 49 | return Err("This account is root account.".into()); 50 | } else { 51 | account.delete(&txn).await?; 52 | } 53 | } 54 | txn.commit().await?; 55 | Ok(()) 56 | } 57 | -------------------------------------------------------------------------------- /src/cli/user/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cull; 2 | pub mod delete; 3 | pub mod prune; 4 | 5 | use crate::consts::UserIdentifier; 6 | use clap::{ArgGroup, Parser, Subcommand}; 7 | use cull::cull; 8 | use delete::delete; 9 | use prune::prune; 10 | 11 | #[derive(Debug, Parser)] 12 | #[command(name = "user")] 13 | pub struct UserCommand { 14 | #[command(subcommand)] 15 | pub subcmd: UserSubCommand, 16 | } 17 | 18 | #[derive(Debug, Subcommand)] 19 | pub enum UserSubCommand { 20 | Cull { 21 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 22 | config_path: String, 23 | }, 24 | #[command(group( 25 | ArgGroup::new("user_delete") 26 | .required(true) 27 | .args(&["id", "username"]) 28 | ), 29 | about = "Delete user account(s)", 30 | long_about = "Delete remote user account(s) by ID or username. Need specify either ID or username.")] 31 | Delete { 32 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 33 | config_path: String, 34 | #[arg( 35 | short = 'i', 36 | long = "id", 37 | value_delimiter = ',', 38 | help = "Id of user you want to delete. You can specify multiple IDs with comma. e.g. -i a4ct2ps000,a3tghk0000" 39 | )] 40 | id: Option>, 41 | #[arg( 42 | short = 'u', 43 | long = "username", 44 | value_delimiter = ',', 45 | help = "Username of user you want to delete. You can specify multiple usernames with comma. e.g. -u alice,bob" 46 | )] 47 | user: Option>, 48 | }, 49 | Prune { 50 | #[arg(short = 'c', long = "config", default_value = ".config/default.yml")] 51 | config_path: String, 52 | #[arg(short = 'H', long = "host")] 53 | host: Option, 54 | #[arg(short = 'n', long = "no-note", action = clap::ArgAction::SetTrue)] 55 | note: bool, 56 | #[arg(short = 'f', long = "no-follow", action = clap::ArgAction::SetTrue)] 57 | follow: bool, 58 | }, 59 | } 60 | 61 | impl UserCommand { 62 | pub async fn exec(&self) -> Result<(), Box> { 63 | match &self.subcmd { 64 | UserSubCommand::Cull { config_path } => { 65 | cull(config_path).await?; 66 | } 67 | UserSubCommand::Delete { 68 | config_path, 69 | id, 70 | user, 71 | } => { 72 | let id_ref = id 73 | .as_ref() 74 | .map(|v| v.iter().map(|s| s.as_str()).collect::>()); 75 | delete(config_path, id_ref, user.clone()).await?; 76 | } 77 | UserSubCommand::Prune { 78 | config_path, 79 | host, 80 | note, 81 | follow, 82 | } => { 83 | let refs = host.as_deref(); 84 | prune(config_path, refs, *note, *follow).await?; 85 | } 86 | } 87 | Ok(()) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/cli/user/prune.rs: -------------------------------------------------------------------------------- 1 | // アカウントをまとめて削除する 2 | 3 | use sea_orm::{ColumnTrait, EntityTrait, ModelTrait, QueryFilter, TransactionTrait}; 4 | 5 | use crate::db::postgres::connect_pg; 6 | use crate::entities::{prelude::*, user}; 7 | 8 | pub async fn prune( 9 | config_path: &str, 10 | host: Option<&str>, 11 | zero_note: bool, 12 | no_follow: bool, 13 | ) -> Result<(), Box> { 14 | let pg_client = connect_pg(config_path).await?; 15 | let txn = pg_client.begin().await?; 16 | // need to output logs 17 | tracing_subscriber::fmt() 18 | .with_max_level(tracing::Level::INFO) 19 | .init(); 20 | 21 | let mut query = User::find(); 22 | 23 | if let Some(host) = host { 24 | query = query.filter(user::Column::Host.eq(host)); 25 | } else { 26 | query = query.filter(user::Column::Host.is_not_null()); 27 | } 28 | 29 | if zero_note { 30 | query = query.filter(user::Column::NotesCount.eq(0)); 31 | } 32 | 33 | if no_follow { 34 | query = query.filter( 35 | user::Column::FollowersCount 36 | .eq(0) 37 | .and(user::Column::FollowingCount.eq(0)), 38 | ); 39 | } 40 | 41 | let users = query.all(&pg_client).await?; 42 | 43 | for user in users { 44 | user.delete(&txn).await?; 45 | } 46 | txn.commit().await?; 47 | Ok(()) 48 | } 49 | -------------------------------------------------------------------------------- /src/cli/vapid/generate.rs: -------------------------------------------------------------------------------- 1 | pub fn gen() -> Result<(), Box> { 2 | let key = crate::util::vapid::generate()?; 3 | let style = anstyle::Style::new().fg_color(Some(anstyle::AnsiColor::Red.into())); 4 | println!("{style}Please copy the following keys and paste them into Service Worker Settings in control panel.{style:#}"); 5 | println!("Private Key: {}", key.private_key); 6 | println!("Public Key: {}", key.public_key); 7 | Ok(()) 8 | } 9 | -------------------------------------------------------------------------------- /src/cli/vapid/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod generate; 2 | 3 | use clap::{Parser, Subcommand}; 4 | 5 | #[derive(Debug, Parser)] 6 | pub struct WebpushCommand { 7 | #[command(subcommand)] 8 | pub subcmd: WebpushSubCommand, 9 | } 10 | 11 | #[derive(Debug, Subcommand)] 12 | pub enum WebpushSubCommand { 13 | #[command(about = "Generate VAPID keys")] 14 | Generate, 15 | } 16 | 17 | impl WebpushCommand { 18 | pub fn exec(&self) -> Result<(), Box> { 19 | match &self.subcmd { 20 | WebpushSubCommand::Generate => { 21 | crate::cli::vapid::generate::gen()?; 22 | } 23 | } 24 | Ok(()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/config.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::{fs, path::Path}; 3 | use syntect::easy::HighlightLines; 4 | use syntect::highlighting::{Style, ThemeSet}; 5 | use syntect::parsing::SyntaxSet; 6 | use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; 7 | 8 | #[derive(Debug, Serialize, Deserialize)] 9 | #[serde(rename_all = "camelCase")] 10 | pub struct MisskeyConfig { 11 | pub publish_tarball_instead_of_provide_repository_url: Option, 12 | pub setup_password: Option, 13 | pub url: String, 14 | pub port: u64, 15 | pub db: DbConfig, 16 | pub db_replications: bool, 17 | pub db_slaves: Option>, 18 | pub redis: RedisConfig, 19 | pub redis_for_pubsub: Option, 20 | pub redis_for_job_queue: Option, 21 | pub redis_for_timelines: Option, 22 | #[serde(rename = "fulltextSearch")] 23 | pub full_text_search: Option, 24 | pub meilisearch: Option, 25 | pub id: IdMethod, 26 | pub serde_for_backend: Option, 27 | pub serde_for_frontend: Option, 28 | pub disable_hsts: Option, 29 | pub cluster_limit: Option, 30 | pub deliver_job_concurrency: Option, 31 | pub inbox_job_concurrency: Option, 32 | pub relationship_job_concurrency: Option, 33 | pub deliver_job_per_sec: Option, 34 | pub inbox_job_per_sec: Option, 35 | pub relationship_job_per_sec: Option, 36 | pub deliver_job_max_attempts: Option, 37 | pub inbox_job_max_attempts: Option, 38 | pub outgoing_address: Option, 39 | pub outgoing_address_family: Option, 40 | pub proxy: Option, 41 | pub proxy_bypass_hosts: Option>, 42 | pub proxy_smtp: Option, 43 | pub media_proxy: Option, 44 | pub proxy_remote_files: bool, 45 | pub video_thumbnail_generator: Option, 46 | pub sign_to_activity_pub_get: bool, 47 | pub allowed_private_networks: Option>, 48 | pub max_file_size: Option, 49 | pub pid_file: Option, 50 | pub per_channel_max_note_cache_count: Option, 51 | pub per_user_notifications_max_count: Option, 52 | pub deactivate_antenna_threshold: Option, 53 | } 54 | 55 | #[derive(Debug, Serialize, Deserialize)] 56 | pub struct DbConfig { 57 | pub host: String, 58 | pub port: u64, 59 | pub db: String, 60 | pub user: String, 61 | pub pass: String, 62 | pub disable_cache: Option, 63 | pub extra: Option, 64 | } 65 | 66 | #[derive(Debug, Serialize, Deserialize)] 67 | pub struct DbExtraConfig { 68 | ssl: bool, 69 | } 70 | 71 | #[derive(Debug, Serialize, Deserialize)] 72 | pub struct RedisConfig { 73 | pub host: String, 74 | pub port: u64, 75 | pub family: Option, 76 | pub pass: Option, 77 | pub prefix: Option, 78 | pub db: Option, 79 | } 80 | 81 | #[derive(Debug, Serialize, Deserialize)] 82 | pub enum RedisFamily { 83 | Both = 0, 84 | IPv4 = 4, 85 | IPv6 = 6, 86 | } 87 | 88 | #[derive(Debug, Serialize, Deserialize, Clone)] 89 | pub struct FullTextSearch { 90 | pub provider: FullTextSearchProvider, 91 | } 92 | 93 | #[derive(Debug, Serialize, Deserialize, Clone)] 94 | #[serde(rename_all = "camelCase")] 95 | pub enum FullTextSearchProvider { 96 | #[serde(rename = "sqlLike")] 97 | SqlLike, 98 | #[serde(rename = "sqlPgroonga")] 99 | SqlPgroonga, 100 | #[serde(rename = "meilisearch")] 101 | Meilisearch, 102 | } 103 | 104 | #[derive(Debug, Serialize, Deserialize, Clone)] 105 | #[serde(rename_all = "camelCase")] 106 | pub struct MeilisearchConfig { 107 | pub host: String, 108 | pub port: u64, 109 | pub api_key: String, 110 | pub ssl: bool, 111 | pub index: String, 112 | pub scope: Option, 113 | } 114 | 115 | #[derive(Debug, Serialize, Deserialize, Clone)] 116 | #[serde(rename_all = "lowercase")] 117 | pub enum MeilisearchScope { 118 | Local, 119 | Global, 120 | Custom(Vec), 121 | } 122 | 123 | #[derive(Debug, Default, Serialize, Deserialize)] 124 | #[serde(rename_all = "lowercase")] 125 | pub enum IdMethod { 126 | Aid, 127 | #[default] 128 | Aidx, 129 | Meid, 130 | Ulid, 131 | ObjectId, 132 | } 133 | 134 | #[derive(Debug, Serialize, Deserialize)] 135 | #[serde(rename_all = "camelCase")] 136 | pub struct SentryForBackendConfig { 137 | pub enable_node_profiling: bool, 138 | pub options: Option, 139 | } 140 | 141 | #[derive(Debug, Serialize, Deserialize)] 142 | #[serde(rename_all = "camelCase")] 143 | pub struct SentryForFrontendConfig { 144 | pub options: Option, 145 | } 146 | 147 | #[derive(Debug, Serialize, Deserialize)] 148 | pub struct SentryOptions { 149 | pub dsn: String, 150 | } 151 | 152 | #[derive(Debug, Serialize, Deserialize)] 153 | #[serde(rename_all = "lowercase")] 154 | pub enum OutgoingAddressFamily { 155 | IPv4, 156 | IPv6, 157 | Dual, 158 | } 159 | 160 | pub fn load_config(config_path: &str) -> Result> { 161 | let config_path = Path::new(config_path); 162 | let config_content = fs::read_to_string(config_path).expect("Failed to read config file"); 163 | let config: MisskeyConfig = 164 | serde_yml::from_str(&config_content).expect("Failed to parse config file"); 165 | Ok(config) 166 | } 167 | 168 | pub fn print_config(config: &MisskeyConfig) -> Result<(), Box> { 169 | let json = serde_json::to_string_pretty(config)?; 170 | let ps = SyntaxSet::load_defaults_newlines(); 171 | let ts = ThemeSet::load_defaults(); 172 | 173 | let syntax = ps.find_syntax_by_extension("json").unwrap(); 174 | let mut h = HighlightLines::new(syntax, &ts.themes["Solarized (dark)"]); 175 | for line in LinesWithEndings::from(&json) { 176 | let ranges: Vec<(Style, &str)> = h.highlight_line(line, &ps).unwrap(); 177 | let escaped = as_24_bit_terminal_escaped(&ranges[..], true); 178 | println!("{}", escaped); 179 | } 180 | Ok(()) 181 | } 182 | -------------------------------------------------------------------------------- /src/consts.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::time::SystemTime; 3 | 4 | #[derive(Debug, Serialize, Deserialize)] 5 | #[serde(rename_all = "camelCase")] 6 | pub struct MeiliNotes { 7 | pub id: String, 8 | pub created_at: SystemTime, 9 | pub user_id: String, 10 | pub user_host: Option, 11 | pub channel_id: Option, 12 | pub cw: Option, 13 | pub text: Option, 14 | pub tags: Vec, 15 | } 16 | 17 | #[derive(Debug, Serialize, Deserialize, Clone)] 18 | pub struct UserIdentifier { 19 | pub username: String, 20 | pub host: String, 21 | } 22 | 23 | impl std::str::FromStr for UserIdentifier { 24 | type Err = String; 25 | 26 | fn from_str(s: &str) -> Result { 27 | let parts: Vec<&str> = s.split('@').collect(); 28 | match parts.len() { 29 | 2 => Ok(UserIdentifier { 30 | username: parts[0].to_string(), 31 | host: parts[1].to_string(), 32 | }), 33 | _ => Err("Invalid user identifier".to_string()), 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/db/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod postgres; 2 | pub mod redis; 3 | -------------------------------------------------------------------------------- /src/db/postgres.rs: -------------------------------------------------------------------------------- 1 | use sea_orm::{ConnectOptions, Database, DatabaseConnection, DbConn, DbErr}; 2 | 3 | use crate::config; 4 | 5 | pub async fn connect_pg(config_path: &str) -> Result { 6 | let config = config::load_config(config_path).unwrap(); 7 | let db_url = format!( 8 | "postgres://{}:{}@{}:{}/{}", 9 | config.db.user, config.db.pass, config.db.host, config.db.port, config.db.db 10 | ); 11 | 12 | let mut opt = ConnectOptions::new(&db_url); 13 | opt 14 | .sqlx_logging(true) 15 | .sqlx_logging_level(log::LevelFilter::Info) 16 | .min_connections(2) 17 | .max_connections(100); 18 | 19 | let db: DatabaseConnection = Database::connect(opt).await?; 20 | Ok(db) 21 | } 22 | -------------------------------------------------------------------------------- /src/db/redis.rs: -------------------------------------------------------------------------------- 1 | use redis::aio::MultiplexedConnection; 2 | use redis::{Client, RedisResult}; 3 | 4 | use crate::config; 5 | 6 | #[allow(dead_code)] 7 | pub async fn connect(confing_path: &str) -> RedisResult { 8 | let config = config::load_config(confing_path).unwrap(); 9 | let redis_url = format!("redis://{}:{}/", config.redis.host, config.redis.port,); 10 | let client = Client::open(redis_url).unwrap(); 11 | let con = client.get_multiplexed_tokio_connection().await.unwrap(); 12 | Ok(con) 13 | } 14 | -------------------------------------------------------------------------------- /src/entities/abuse_report_notification_recipient.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "abuse_report_notification_recipient")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "isActive")] 12 | pub is_active: bool, 13 | #[sea_orm(column_name = "updatedAt")] 14 | pub updated_at: DateTimeWithTimeZone, 15 | pub name: String, 16 | pub method: String, 17 | #[sea_orm(column_name = "userId")] 18 | pub user_id: Option, 19 | #[sea_orm(column_name = "systemWebhookId")] 20 | pub system_webhook_id: Option, 21 | } 22 | 23 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 24 | pub enum Relation { 25 | #[sea_orm( 26 | belongs_to = "super::system_webhook::Entity", 27 | from = "Column::SystemWebhookId", 28 | to = "super::system_webhook::Column::Id", 29 | on_update = "NoAction", 30 | on_delete = "Cascade" 31 | )] 32 | SystemWebhook, 33 | #[sea_orm( 34 | belongs_to = "super::user::Entity", 35 | from = "Column::UserId", 36 | to = "super::user::Column::Id", 37 | on_update = "NoAction", 38 | on_delete = "Cascade" 39 | )] 40 | User, 41 | #[sea_orm( 42 | belongs_to = "super::user_profile::Entity", 43 | from = "Column::UserId", 44 | to = "super::user_profile::Column::UserId", 45 | on_update = "NoAction", 46 | on_delete = "Cascade" 47 | )] 48 | UserProfile, 49 | } 50 | 51 | impl Related for Entity { 52 | fn to() -> RelationDef { 53 | Relation::SystemWebhook.def() 54 | } 55 | } 56 | 57 | impl Related for Entity { 58 | fn to() -> RelationDef { 59 | Relation::User.def() 60 | } 61 | } 62 | 63 | impl Related for Entity { 64 | fn to() -> RelationDef { 65 | Relation::UserProfile.def() 66 | } 67 | } 68 | 69 | impl ActiveModelBehavior for ActiveModel {} 70 | -------------------------------------------------------------------------------- /src/entities/abuse_user_report.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "abuse_user_report")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "targetUserId")] 12 | pub target_user_id: String, 13 | #[sea_orm(column_name = "reporterId")] 14 | pub reporter_id: String, 15 | #[sea_orm(column_name = "assigneeId")] 16 | pub assignee_id: Option, 17 | pub resolved: bool, 18 | pub comment: String, 19 | #[sea_orm(column_name = "targetUserHost")] 20 | pub target_user_host: Option, 21 | #[sea_orm(column_name = "reporterHost")] 22 | pub reporter_host: Option, 23 | pub forwarded: bool, 24 | #[sea_orm(column_name = "moderationNote")] 25 | pub moderation_note: String, 26 | #[sea_orm(column_name = "resolvedAs")] 27 | pub resolved_as: Option, 28 | } 29 | 30 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 31 | pub enum Relation { 32 | #[sea_orm( 33 | belongs_to = "super::user::Entity", 34 | from = "Column::ReporterId", 35 | to = "super::user::Column::Id", 36 | on_update = "NoAction", 37 | on_delete = "Cascade" 38 | )] 39 | User3, 40 | #[sea_orm( 41 | belongs_to = "super::user::Entity", 42 | from = "Column::AssigneeId", 43 | to = "super::user::Column::Id", 44 | on_update = "NoAction", 45 | on_delete = "SetNull" 46 | )] 47 | User2, 48 | #[sea_orm( 49 | belongs_to = "super::user::Entity", 50 | from = "Column::TargetUserId", 51 | to = "super::user::Column::Id", 52 | on_update = "NoAction", 53 | on_delete = "Cascade" 54 | )] 55 | User1, 56 | } 57 | 58 | impl ActiveModelBehavior for ActiveModel {} 59 | -------------------------------------------------------------------------------- /src/entities/access_token.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "access_token")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | pub token: String, 12 | pub hash: String, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "appId")] 16 | pub app_id: Option, 17 | #[sea_orm(column_name = "lastUsedAt")] 18 | pub last_used_at: Option, 19 | pub session: Option, 20 | pub name: Option, 21 | pub description: Option, 22 | #[sea_orm(column_name = "iconUrl")] 23 | pub icon_url: Option, 24 | pub permission: Vec, 25 | pub fetched: bool, 26 | } 27 | 28 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 29 | pub enum Relation { 30 | #[sea_orm( 31 | belongs_to = "super::app::Entity", 32 | from = "Column::AppId", 33 | to = "super::app::Column::Id", 34 | on_update = "NoAction", 35 | on_delete = "Cascade" 36 | )] 37 | App, 38 | #[sea_orm( 39 | belongs_to = "super::user::Entity", 40 | from = "Column::UserId", 41 | to = "super::user::Column::Id", 42 | on_update = "NoAction", 43 | on_delete = "Cascade" 44 | )] 45 | User, 46 | } 47 | 48 | impl Related for Entity { 49 | fn to() -> RelationDef { 50 | Relation::App.def() 51 | } 52 | } 53 | 54 | impl Related for Entity { 55 | fn to() -> RelationDef { 56 | Relation::User.def() 57 | } 58 | } 59 | 60 | impl ActiveModelBehavior for ActiveModel {} 61 | -------------------------------------------------------------------------------- /src/entities/ad.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "ad")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "expiresAt")] 12 | pub expires_at: DateTimeWithTimeZone, 13 | pub place: String, 14 | pub priority: String, 15 | pub url: String, 16 | #[sea_orm(column_name = "imageUrl")] 17 | pub image_url: String, 18 | pub memo: String, 19 | pub ratio: i32, 20 | #[sea_orm(column_name = "startsAt")] 21 | pub starts_at: DateTimeWithTimeZone, 22 | #[sea_orm(column_name = "dayOfWeek")] 23 | pub day_of_week: i32, 24 | } 25 | 26 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 27 | pub enum Relation {} 28 | 29 | impl ActiveModelBehavior for ActiveModel {} 30 | -------------------------------------------------------------------------------- /src/entities/announcement.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "announcement")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | pub text: String, 12 | pub title: String, 13 | #[sea_orm(column_name = "imageUrl")] 14 | pub image_url: Option, 15 | #[sea_orm(column_name = "updatedAt")] 16 | pub updated_at: Option, 17 | pub display: String, 18 | #[sea_orm(column_name = "needConfirmationToRead")] 19 | pub need_confirmation_to_read: bool, 20 | #[sea_orm(column_name = "isActive")] 21 | pub is_active: bool, 22 | #[sea_orm(column_name = "forExistingUsers")] 23 | pub for_existing_users: bool, 24 | #[sea_orm(column_name = "userId")] 25 | pub user_id: Option, 26 | pub icon: String, 27 | pub silence: bool, 28 | } 29 | 30 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 31 | pub enum Relation { 32 | #[sea_orm(has_many = "super::announcement_read::Entity")] 33 | AnnouncementRead, 34 | #[sea_orm( 35 | belongs_to = "super::user::Entity", 36 | from = "Column::UserId", 37 | to = "super::user::Column::Id", 38 | on_update = "NoAction", 39 | on_delete = "Cascade" 40 | )] 41 | User, 42 | } 43 | 44 | impl Related for Entity { 45 | fn to() -> RelationDef { 46 | Relation::AnnouncementRead.def() 47 | } 48 | } 49 | 50 | impl Related for Entity { 51 | fn to() -> RelationDef { 52 | Relation::User.def() 53 | } 54 | } 55 | 56 | impl ActiveModelBehavior for ActiveModel {} 57 | -------------------------------------------------------------------------------- /src/entities/announcement_read.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "announcement_read")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "announcementId")] 14 | pub announcement_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::announcement::Entity", 21 | from = "Column::AnnouncementId", 22 | to = "super::announcement::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Announcement, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Announcement.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/antenna.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::AntennaSrcEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "antenna")] 9 | pub struct Model { 10 | #[sea_orm(primary_key, auto_increment = false)] 11 | pub id: String, 12 | #[sea_orm(column_name = "userId")] 13 | pub user_id: String, 14 | pub name: String, 15 | pub src: AntennaSrcEnum, 16 | #[sea_orm(column_name = "userListId")] 17 | pub user_list_id: Option, 18 | #[sea_orm(column_type = "JsonBinary")] 19 | pub keywords: Json, 20 | #[sea_orm(column_name = "withFile")] 21 | pub with_file: bool, 22 | pub expression: Option, 23 | #[sea_orm(column_name = "caseSensitive")] 24 | pub case_sensitive: bool, 25 | #[sea_orm(column_name = "withReplies")] 26 | pub with_replies: bool, 27 | pub users: Vec, 28 | #[sea_orm(column_name = "excludeKeywords", column_type = "JsonBinary")] 29 | pub exclude_keywords: Json, 30 | #[sea_orm(column_name = "lastUsedAt")] 31 | pub last_used_at: DateTimeWithTimeZone, 32 | #[sea_orm(column_name = "isActive")] 33 | pub is_active: bool, 34 | #[sea_orm(column_name = "localOnly")] 35 | pub local_only: bool, 36 | #[sea_orm(column_name = "excludeBots")] 37 | pub exclude_bots: bool, 38 | } 39 | 40 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 41 | pub enum Relation { 42 | #[sea_orm( 43 | belongs_to = "super::user::Entity", 44 | from = "Column::UserId", 45 | to = "super::user::Column::Id", 46 | on_update = "NoAction", 47 | on_delete = "Cascade" 48 | )] 49 | User, 50 | #[sea_orm( 51 | belongs_to = "super::user_list::Entity", 52 | from = "Column::UserListId", 53 | to = "super::user_list::Column::Id", 54 | on_update = "NoAction", 55 | on_delete = "Cascade" 56 | )] 57 | UserList, 58 | } 59 | 60 | impl Related for Entity { 61 | fn to() -> RelationDef { 62 | Relation::User.def() 63 | } 64 | } 65 | 66 | impl Related for Entity { 67 | fn to() -> RelationDef { 68 | Relation::UserList.def() 69 | } 70 | } 71 | 72 | impl ActiveModelBehavior for ActiveModel {} 73 | -------------------------------------------------------------------------------- /src/entities/app.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "app")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: Option, 13 | pub secret: String, 14 | pub name: String, 15 | pub description: String, 16 | pub permission: Vec, 17 | #[sea_orm(column_name = "callbackUrl")] 18 | pub callback_url: Option, 19 | } 20 | 21 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 22 | pub enum Relation { 23 | #[sea_orm(has_many = "super::access_token::Entity")] 24 | AccessToken, 25 | #[sea_orm(has_many = "super::auth_session::Entity")] 26 | AuthSession, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "SetNull" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::AccessToken.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::AuthSession.def() 46 | } 47 | } 48 | 49 | impl Related for Entity { 50 | fn to() -> RelationDef { 51 | Relation::User.def() 52 | } 53 | } 54 | 55 | impl ActiveModelBehavior for ActiveModel {} 56 | -------------------------------------------------------------------------------- /src/entities/auth_session.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "auth_session")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | pub token: String, 12 | #[sea_orm(column_name = "userId")] 13 | pub user_id: Option, 14 | #[sea_orm(column_name = "appId")] 15 | pub app_id: String, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm( 21 | belongs_to = "super::app::Entity", 22 | from = "Column::AppId", 23 | to = "super::app::Column::Id", 24 | on_update = "NoAction", 25 | on_delete = "Cascade" 26 | )] 27 | App, 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::UserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User, 36 | } 37 | 38 | impl Related for Entity { 39 | fn to() -> RelationDef { 40 | Relation::App.def() 41 | } 42 | } 43 | 44 | impl Related for Entity { 45 | fn to() -> RelationDef { 46 | Relation::User.def() 47 | } 48 | } 49 | 50 | impl ActiveModelBehavior for ActiveModel {} 51 | -------------------------------------------------------------------------------- /src/entities/avatar_decoration.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "avatar_decoration")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "updatedAt")] 12 | pub updated_at: Option, 13 | pub url: String, 14 | pub name: String, 15 | pub description: String, 16 | #[sea_orm(column_name = "roleIdsThatCanBeUsedThisDecoration")] 17 | pub role_ids_that_can_be_used_this_decoration: Vec, 18 | } 19 | 20 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 21 | pub enum Relation {} 22 | 23 | impl ActiveModelBehavior for ActiveModel {} 24 | -------------------------------------------------------------------------------- /src/entities/blocking.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "blocking")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "blockeeId")] 12 | pub blockee_id: String, 13 | #[sea_orm(column_name = "blockerId")] 14 | pub blocker_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::BlockerId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User2, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::BlockeeId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User1, 35 | } 36 | 37 | impl ActiveModelBehavior for ActiveModel {} 38 | -------------------------------------------------------------------------------- /src/entities/bubble_game_record.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "bubble_game_record")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "seededAt")] 14 | pub seeded_at: DateTimeWithTimeZone, 15 | pub seed: String, 16 | #[sea_orm(column_name = "gameVersion")] 17 | pub game_version: i32, 18 | #[sea_orm(column_name = "gameMode")] 19 | pub game_mode: String, 20 | pub score: i32, 21 | #[sea_orm(column_type = "JsonBinary")] 22 | pub logs: Json, 23 | #[sea_orm(column_name = "isVerified")] 24 | pub is_verified: bool, 25 | } 26 | 27 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 28 | pub enum Relation { 29 | #[sea_orm( 30 | belongs_to = "super::user::Entity", 31 | from = "Column::UserId", 32 | to = "super::user::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | User, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::User.def() 42 | } 43 | } 44 | 45 | impl ActiveModelBehavior for ActiveModel {} 46 | -------------------------------------------------------------------------------- /src/entities/channel.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "channel")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "lastNotedAt")] 12 | pub last_noted_at: Option, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: Option, 15 | pub name: String, 16 | pub description: Option, 17 | #[sea_orm(column_name = "bannerId")] 18 | pub banner_id: Option, 19 | #[sea_orm(column_name = "notesCount")] 20 | pub notes_count: i32, 21 | #[sea_orm(column_name = "usersCount")] 22 | pub users_count: i32, 23 | #[sea_orm(column_name = "pinnedNoteIds")] 24 | pub pinned_note_ids: Vec, 25 | pub color: String, 26 | #[sea_orm(column_name = "isArchived")] 27 | pub is_archived: bool, 28 | #[sea_orm(column_name = "isSensitive")] 29 | pub is_sensitive: bool, 30 | #[sea_orm(column_name = "allowRenoteToExternal")] 31 | pub allow_renote_to_external: bool, 32 | } 33 | 34 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 35 | pub enum Relation { 36 | #[sea_orm(has_many = "super::channel_favorite::Entity")] 37 | ChannelFavorite, 38 | #[sea_orm(has_many = "super::channel_following::Entity")] 39 | ChannelFollowing, 40 | #[sea_orm(has_many = "super::channel_note_pining::Entity")] 41 | ChannelNotePining, 42 | #[sea_orm( 43 | belongs_to = "super::drive_file::Entity", 44 | from = "Column::BannerId", 45 | to = "super::drive_file::Column::Id", 46 | on_update = "NoAction", 47 | on_delete = "SetNull" 48 | )] 49 | DriveFile, 50 | #[sea_orm(has_many = "super::note::Entity")] 51 | Note, 52 | #[sea_orm( 53 | belongs_to = "super::user::Entity", 54 | from = "Column::UserId", 55 | to = "super::user::Column::Id", 56 | on_update = "NoAction", 57 | on_delete = "SetNull" 58 | )] 59 | User, 60 | } 61 | 62 | impl Related for Entity { 63 | fn to() -> RelationDef { 64 | Relation::ChannelFavorite.def() 65 | } 66 | } 67 | 68 | impl Related for Entity { 69 | fn to() -> RelationDef { 70 | Relation::ChannelFollowing.def() 71 | } 72 | } 73 | 74 | impl Related for Entity { 75 | fn to() -> RelationDef { 76 | Relation::ChannelNotePining.def() 77 | } 78 | } 79 | 80 | impl Related for Entity { 81 | fn to() -> RelationDef { 82 | Relation::DriveFile.def() 83 | } 84 | } 85 | 86 | impl Related for Entity { 87 | fn to() -> RelationDef { 88 | Relation::Note.def() 89 | } 90 | } 91 | 92 | impl Related for Entity { 93 | fn to() -> RelationDef { 94 | Relation::User.def() 95 | } 96 | } 97 | 98 | impl ActiveModelBehavior for ActiveModel {} 99 | -------------------------------------------------------------------------------- /src/entities/channel_favorite.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "channel_favorite")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "channelId")] 12 | pub channel_id: String, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::channel::Entity", 21 | from = "Column::ChannelId", 22 | to = "super::channel::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Channel, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Channel.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/channel_following.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "channel_following")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "followeeId")] 12 | pub followee_id: String, 13 | #[sea_orm(column_name = "followerId")] 14 | pub follower_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::channel::Entity", 21 | from = "Column::FolloweeId", 22 | to = "super::channel::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Channel, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::FollowerId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Channel.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/channel_note_pining.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "channel_note_pining")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "channelId")] 14 | pub channel_id: String, 15 | #[sea_orm(column_name = "noteId")] 16 | pub note_id: String, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::channel::Entity", 23 | from = "Column::ChannelId", 24 | to = "super::channel::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | Channel, 29 | #[sea_orm( 30 | belongs_to = "super::note::Entity", 31 | from = "Column::NoteId", 32 | to = "super::note::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | Note, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::Channel.def() 42 | } 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::Note.def() 48 | } 49 | } 50 | 51 | impl ActiveModelBehavior for ActiveModel {} 52 | -------------------------------------------------------------------------------- /src/entities/clip.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "clip")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub name: String, 14 | #[sea_orm(column_name = "isPublic")] 15 | pub is_public: bool, 16 | pub description: Option, 17 | #[sea_orm(column_name = "lastClippedAt")] 18 | pub last_clipped_at: Option, 19 | } 20 | 21 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 22 | pub enum Relation { 23 | #[sea_orm(has_many = "super::clip_favorite::Entity")] 24 | ClipFavorite, 25 | #[sea_orm(has_many = "super::clip_note::Entity")] 26 | ClipNote, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::ClipFavorite.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::ClipNote.def() 46 | } 47 | } 48 | 49 | impl Related for Entity { 50 | fn to() -> RelationDef { 51 | Relation::User.def() 52 | } 53 | } 54 | 55 | impl ActiveModelBehavior for ActiveModel {} 56 | -------------------------------------------------------------------------------- /src/entities/clip_favorite.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "clip_favorite")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "clipId")] 14 | pub clip_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::clip::Entity", 21 | from = "Column::ClipId", 22 | to = "super::clip::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Clip, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Clip.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/clip_note.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "clip_note")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "noteId")] 12 | pub note_id: String, 13 | #[sea_orm(column_name = "clipId")] 14 | pub clip_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::clip::Entity", 21 | from = "Column::ClipId", 22 | to = "super::clip::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Clip, 27 | #[sea_orm( 28 | belongs_to = "super::note::Entity", 29 | from = "Column::NoteId", 30 | to = "super::note::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | Note, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Clip.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::Note.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/drive_file.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "drive_file")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: Option, 13 | #[sea_orm(column_name = "userHost")] 14 | pub user_host: Option, 15 | pub md5: String, 16 | pub name: String, 17 | pub r#type: String, 18 | pub size: i32, 19 | pub comment: Option, 20 | #[sea_orm(column_type = "JsonBinary")] 21 | pub properties: Json, 22 | #[sea_orm(column_name = "storedInternal")] 23 | pub stored_internal: bool, 24 | pub url: String, 25 | #[sea_orm(column_name = "thumbnailUrl")] 26 | pub thumbnail_url: Option, 27 | #[sea_orm(column_name = "webpublicUrl")] 28 | pub webpublic_url: Option, 29 | #[sea_orm(column_name = "accessKey", unique)] 30 | pub access_key: Option, 31 | #[sea_orm(column_name = "thumbnailAccessKey", unique)] 32 | pub thumbnail_access_key: Option, 33 | #[sea_orm(column_name = "webpublicAccessKey", unique)] 34 | pub webpublic_access_key: Option, 35 | pub uri: Option, 36 | pub src: Option, 37 | #[sea_orm(column_name = "folderId")] 38 | pub folder_id: Option, 39 | #[sea_orm(column_name = "isSensitive")] 40 | pub is_sensitive: bool, 41 | #[sea_orm(column_name = "isLink")] 42 | pub is_link: bool, 43 | pub blurhash: Option, 44 | #[sea_orm(column_name = "webpublicType")] 45 | pub webpublic_type: Option, 46 | #[sea_orm(column_name = "requestHeaders", column_type = "JsonBinary", nullable)] 47 | pub request_headers: Option, 48 | #[sea_orm(column_name = "requestIp")] 49 | pub request_ip: Option, 50 | #[sea_orm(column_name = "maybeSensitive")] 51 | pub maybe_sensitive: bool, 52 | #[sea_orm(column_name = "maybePorn")] 53 | pub maybe_porn: bool, 54 | } 55 | 56 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 57 | pub enum Relation { 58 | #[sea_orm(has_many = "super::channel::Entity")] 59 | Channel, 60 | #[sea_orm( 61 | belongs_to = "super::drive_folder::Entity", 62 | from = "Column::FolderId", 63 | to = "super::drive_folder::Column::Id", 64 | on_update = "NoAction", 65 | on_delete = "SetNull" 66 | )] 67 | DriveFolder, 68 | #[sea_orm(has_many = "super::messaging_message::Entity")] 69 | MessagingMessage, 70 | #[sea_orm(has_many = "super::page::Entity")] 71 | Page, 72 | #[sea_orm( 73 | belongs_to = "super::user::Entity", 74 | from = "Column::UserId", 75 | to = "super::user::Column::Id", 76 | on_update = "NoAction", 77 | on_delete = "SetNull" 78 | )] 79 | User, 80 | } 81 | 82 | impl Related for Entity { 83 | fn to() -> RelationDef { 84 | Relation::Channel.def() 85 | } 86 | } 87 | 88 | impl Related for Entity { 89 | fn to() -> RelationDef { 90 | Relation::DriveFolder.def() 91 | } 92 | } 93 | 94 | impl Related for Entity { 95 | fn to() -> RelationDef { 96 | Relation::MessagingMessage.def() 97 | } 98 | } 99 | 100 | impl Related for Entity { 101 | fn to() -> RelationDef { 102 | Relation::Page.def() 103 | } 104 | } 105 | 106 | impl Related for Entity { 107 | fn to() -> RelationDef { 108 | Relation::User.def() 109 | } 110 | } 111 | 112 | impl ActiveModelBehavior for ActiveModel {} 113 | -------------------------------------------------------------------------------- /src/entities/drive_folder.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "drive_folder")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | pub name: String, 12 | #[sea_orm(column_name = "userId")] 13 | pub user_id: Option, 14 | #[sea_orm(column_name = "parentId")] 15 | pub parent_id: Option, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm(has_many = "super::drive_file::Entity")] 21 | DriveFile, 22 | #[sea_orm( 23 | belongs_to = "Entity", 24 | from = "Column::ParentId", 25 | to = "Column::Id", 26 | on_update = "NoAction", 27 | on_delete = "SetNull" 28 | )] 29 | SelfRef, 30 | #[sea_orm( 31 | belongs_to = "super::user::Entity", 32 | from = "Column::UserId", 33 | to = "super::user::Column::Id", 34 | on_update = "NoAction", 35 | on_delete = "Cascade" 36 | )] 37 | User, 38 | } 39 | 40 | impl Related for Entity { 41 | fn to() -> RelationDef { 42 | Relation::DriveFile.def() 43 | } 44 | } 45 | 46 | impl Related for Entity { 47 | fn to() -> RelationDef { 48 | Relation::User.def() 49 | } 50 | } 51 | 52 | impl ActiveModelBehavior for ActiveModel {} 53 | -------------------------------------------------------------------------------- /src/entities/emoji.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "emoji")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "updatedAt")] 12 | pub updated_at: Option, 13 | pub name: String, 14 | pub host: Option, 15 | #[sea_orm(column_name = "originalUrl")] 16 | pub original_url: String, 17 | pub uri: Option, 18 | pub r#type: Option, 19 | pub aliases: Vec, 20 | pub category: Option, 21 | #[sea_orm(column_name = "publicUrl")] 22 | pub public_url: String, 23 | pub license: Option, 24 | #[sea_orm(column_name = "localOnly")] 25 | pub local_only: bool, 26 | #[sea_orm(column_name = "isSensitive")] 27 | pub is_sensitive: bool, 28 | #[sea_orm(column_name = "roleIdsThatCanBeUsedThisEmojiAsReaction")] 29 | pub role_ids_that_can_be_used_this_emoji_as_reaction: Vec, 30 | } 31 | 32 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 33 | pub enum Relation {} 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/flash.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "flash")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "updatedAt")] 12 | pub updated_at: DateTimeWithTimeZone, 13 | pub title: String, 14 | pub summary: String, 15 | #[sea_orm(column_name = "userId")] 16 | pub user_id: String, 17 | pub script: String, 18 | pub permissions: Vec, 19 | #[sea_orm(column_name = "likedCount")] 20 | pub liked_count: i32, 21 | pub visibility: Option, 22 | } 23 | 24 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 25 | pub enum Relation { 26 | #[sea_orm(has_many = "super::flash_like::Entity")] 27 | FlashLike, 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::UserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User, 36 | } 37 | 38 | impl Related for Entity { 39 | fn to() -> RelationDef { 40 | Relation::FlashLike.def() 41 | } 42 | } 43 | 44 | impl Related for Entity { 45 | fn to() -> RelationDef { 46 | Relation::User.def() 47 | } 48 | } 49 | 50 | impl ActiveModelBehavior for ActiveModel {} 51 | -------------------------------------------------------------------------------- /src/entities/flash_like.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "flash_like")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "flashId")] 14 | pub flash_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::flash::Entity", 21 | from = "Column::FlashId", 22 | to = "super::flash::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Flash, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Flash.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/follow_request.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "follow_request")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "followeeId")] 12 | pub followee_id: String, 13 | #[sea_orm(column_name = "followerId")] 14 | pub follower_id: String, 15 | #[sea_orm(column_name = "requestId")] 16 | pub request_id: Option, 17 | #[sea_orm(column_name = "followerHost")] 18 | pub follower_host: Option, 19 | #[sea_orm(column_name = "followerInbox")] 20 | pub follower_inbox: Option, 21 | #[sea_orm(column_name = "followerSharedInbox")] 22 | pub follower_shared_inbox: Option, 23 | #[sea_orm(column_name = "followeeHost")] 24 | pub followee_host: Option, 25 | #[sea_orm(column_name = "followeeInbox")] 26 | pub followee_inbox: Option, 27 | #[sea_orm(column_name = "followeeSharedInbox")] 28 | pub followee_shared_inbox: Option, 29 | #[sea_orm(column_name = "withReplies")] 30 | pub with_replies: bool, 31 | } 32 | 33 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 34 | pub enum Relation { 35 | #[sea_orm( 36 | belongs_to = "super::user::Entity", 37 | from = "Column::FolloweeId", 38 | to = "super::user::Column::Id", 39 | on_update = "NoAction", 40 | on_delete = "Cascade" 41 | )] 42 | User2, 43 | #[sea_orm( 44 | belongs_to = "super::user::Entity", 45 | from = "Column::FollowerId", 46 | to = "super::user::Column::Id", 47 | on_update = "NoAction", 48 | on_delete = "Cascade" 49 | )] 50 | User1, 51 | } 52 | 53 | impl ActiveModelBehavior for ActiveModel {} 54 | -------------------------------------------------------------------------------- /src/entities/following.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "following")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "followeeId")] 12 | pub followee_id: String, 13 | #[sea_orm(column_name = "followerId")] 14 | pub follower_id: String, 15 | #[sea_orm(column_name = "followerHost")] 16 | pub follower_host: Option, 17 | #[sea_orm(column_name = "followerInbox")] 18 | pub follower_inbox: Option, 19 | #[sea_orm(column_name = "followerSharedInbox")] 20 | pub follower_shared_inbox: Option, 21 | #[sea_orm(column_name = "followeeHost")] 22 | pub followee_host: Option, 23 | #[sea_orm(column_name = "followeeInbox")] 24 | pub followee_inbox: Option, 25 | #[sea_orm(column_name = "followeeSharedInbox")] 26 | pub followee_shared_inbox: Option, 27 | pub notify: Option, 28 | #[sea_orm(column_name = "withReplies")] 29 | pub with_replies: bool, 30 | #[sea_orm(column_name = "isFollowerHibernated")] 31 | pub is_follower_hibernated: bool, 32 | } 33 | 34 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 35 | pub enum Relation { 36 | #[sea_orm( 37 | belongs_to = "super::user::Entity", 38 | from = "Column::FolloweeId", 39 | to = "super::user::Column::Id", 40 | on_update = "NoAction", 41 | on_delete = "Cascade" 42 | )] 43 | User2, 44 | #[sea_orm( 45 | belongs_to = "super::user::Entity", 46 | from = "Column::FollowerId", 47 | to = "super::user::Column::Id", 48 | on_update = "NoAction", 49 | on_delete = "Cascade" 50 | )] 51 | User1, 52 | } 53 | 54 | impl ActiveModelBehavior for ActiveModel {} 55 | -------------------------------------------------------------------------------- /src/entities/gallery_like.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "gallery_like")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "postId")] 14 | pub post_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::gallery_post::Entity", 21 | from = "Column::PostId", 22 | to = "super::gallery_post::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | GalleryPost, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::GalleryPost.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/gallery_post.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "gallery_post")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "updatedAt")] 12 | pub updated_at: DateTimeWithTimeZone, 13 | pub title: String, 14 | pub description: Option, 15 | #[sea_orm(column_name = "userId")] 16 | pub user_id: String, 17 | #[sea_orm(column_name = "fileIds")] 18 | pub file_ids: Vec, 19 | #[sea_orm(column_name = "isSensitive")] 20 | pub is_sensitive: bool, 21 | #[sea_orm(column_name = "likedCount")] 22 | pub liked_count: i32, 23 | pub tags: Vec, 24 | } 25 | 26 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 27 | pub enum Relation { 28 | #[sea_orm(has_many = "super::gallery_like::Entity")] 29 | GalleryLike, 30 | #[sea_orm( 31 | belongs_to = "super::user::Entity", 32 | from = "Column::UserId", 33 | to = "super::user::Column::Id", 34 | on_update = "NoAction", 35 | on_delete = "Cascade" 36 | )] 37 | User, 38 | } 39 | 40 | impl Related for Entity { 41 | fn to() -> RelationDef { 42 | Relation::GalleryLike.def() 43 | } 44 | } 45 | 46 | impl Related for Entity { 47 | fn to() -> RelationDef { 48 | Relation::User.def() 49 | } 50 | } 51 | 52 | impl ActiveModelBehavior for ActiveModel {} 53 | -------------------------------------------------------------------------------- /src/entities/hashtag.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "hashtag")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(unique)] 12 | pub name: String, 13 | #[sea_orm(column_name = "mentionedUserIds")] 14 | pub mentioned_user_ids: Vec, 15 | #[sea_orm(column_name = "mentionedUsersCount")] 16 | pub mentioned_users_count: i32, 17 | #[sea_orm(column_name = "mentionedLocalUserIds")] 18 | pub mentioned_local_user_ids: Vec, 19 | #[sea_orm(column_name = "mentionedLocalUsersCount")] 20 | pub mentioned_local_users_count: i32, 21 | #[sea_orm(column_name = "mentionedRemoteUserIds")] 22 | pub mentioned_remote_user_ids: Vec, 23 | #[sea_orm(column_name = "mentionedRemoteUsersCount")] 24 | pub mentioned_remote_users_count: i32, 25 | #[sea_orm(column_name = "attachedUserIds")] 26 | pub attached_user_ids: Vec, 27 | #[sea_orm(column_name = "attachedUsersCount")] 28 | pub attached_users_count: i32, 29 | #[sea_orm(column_name = "attachedLocalUserIds")] 30 | pub attached_local_user_ids: Vec, 31 | #[sea_orm(column_name = "attachedLocalUsersCount")] 32 | pub attached_local_users_count: i32, 33 | #[sea_orm(column_name = "attachedRemoteUserIds")] 34 | pub attached_remote_user_ids: Vec, 35 | #[sea_orm(column_name = "attachedRemoteUsersCount")] 36 | pub attached_remote_users_count: i32, 37 | } 38 | 39 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 40 | pub enum Relation {} 41 | 42 | impl ActiveModelBehavior for ActiveModel {} 43 | -------------------------------------------------------------------------------- /src/entities/instance.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::InstanceSuspensionstateEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "instance")] 9 | pub struct Model { 10 | #[sea_orm(primary_key, auto_increment = false)] 11 | pub id: String, 12 | #[sea_orm(column_name = "firstRetrievedAt")] 13 | pub first_retrieved_at: DateTimeWithTimeZone, 14 | #[sea_orm(unique)] 15 | pub host: String, 16 | #[sea_orm(column_name = "usersCount")] 17 | pub users_count: i32, 18 | #[sea_orm(column_name = "notesCount")] 19 | pub notes_count: i32, 20 | #[sea_orm(column_name = "followingCount")] 21 | pub following_count: i32, 22 | #[sea_orm(column_name = "followersCount")] 23 | pub followers_count: i32, 24 | #[sea_orm(column_name = "latestRequestReceivedAt")] 25 | pub latest_request_received_at: Option, 26 | #[sea_orm(column_name = "isNotResponding")] 27 | pub is_not_responding: bool, 28 | #[sea_orm(column_name = "softwareName")] 29 | pub software_name: Option, 30 | #[sea_orm(column_name = "softwareVersion")] 31 | pub software_version: Option, 32 | #[sea_orm(column_name = "openRegistrations")] 33 | pub open_registrations: Option, 34 | pub name: Option, 35 | pub description: Option, 36 | #[sea_orm(column_name = "maintainerName")] 37 | pub maintainer_name: Option, 38 | #[sea_orm(column_name = "maintainerEmail")] 39 | pub maintainer_email: Option, 40 | #[sea_orm(column_name = "infoUpdatedAt")] 41 | pub info_updated_at: Option, 42 | #[sea_orm(column_name = "suspensionState")] 43 | pub suspension_state: InstanceSuspensionstateEnum, 44 | #[sea_orm(column_name = "iconUrl")] 45 | pub icon_url: Option, 46 | #[sea_orm(column_name = "themeColor")] 47 | pub theme_color: Option, 48 | #[sea_orm(column_name = "faviconUrl")] 49 | pub favicon_url: Option, 50 | #[sea_orm(column_name = "moderationNote")] 51 | pub moderation_note: String, 52 | #[sea_orm(column_name = "notRespondingSince")] 53 | pub not_responding_since: Option, 54 | } 55 | 56 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 57 | pub enum Relation {} 58 | 59 | impl ActiveModelBehavior for ActiveModel {} 60 | -------------------------------------------------------------------------------- /src/entities/messaging_message.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "messaging_message")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "recipientId")] 16 | pub recipient_id: Option, 17 | pub text: Option, 18 | #[sea_orm(column_name = "isRead")] 19 | pub is_read: bool, 20 | #[sea_orm(column_name = "fileId")] 21 | pub file_id: Option, 22 | #[sea_orm(column_name = "groupId")] 23 | pub group_id: Option, 24 | pub reads: Vec, 25 | pub uri: Option, 26 | } 27 | 28 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 29 | pub enum Relation { 30 | #[sea_orm( 31 | belongs_to = "super::drive_file::Entity", 32 | from = "Column::FileId", 33 | to = "super::drive_file::Column::Id", 34 | on_update = "NoAction", 35 | on_delete = "Cascade" 36 | )] 37 | DriveFile, 38 | #[sea_orm( 39 | belongs_to = "super::user::Entity", 40 | from = "Column::UserId", 41 | to = "super::user::Column::Id", 42 | on_update = "NoAction", 43 | on_delete = "Cascade" 44 | )] 45 | User2, 46 | #[sea_orm( 47 | belongs_to = "super::user::Entity", 48 | from = "Column::RecipientId", 49 | to = "super::user::Column::Id", 50 | on_update = "NoAction", 51 | on_delete = "Cascade" 52 | )] 53 | User1, 54 | #[sea_orm( 55 | belongs_to = "super::user_group::Entity", 56 | from = "Column::GroupId", 57 | to = "super::user_group::Column::Id", 58 | on_update = "NoAction", 59 | on_delete = "Cascade" 60 | )] 61 | UserGroup, 62 | } 63 | 64 | impl Related for Entity { 65 | fn to() -> RelationDef { 66 | Relation::DriveFile.def() 67 | } 68 | } 69 | 70 | impl Related for Entity { 71 | fn to() -> RelationDef { 72 | Relation::UserGroup.def() 73 | } 74 | } 75 | 76 | impl ActiveModelBehavior for ActiveModel {} 77 | -------------------------------------------------------------------------------- /src/entities/migrations.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "migrations")] 8 | pub struct Model { 9 | #[sea_orm(primary_key)] 10 | pub id: i32, 11 | pub timestamp: i64, 12 | pub name: String, 13 | } 14 | 15 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 16 | pub enum Relation {} 17 | 18 | impl ActiveModelBehavior for ActiveModel {} 19 | -------------------------------------------------------------------------------- /src/entities/mod.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | pub mod prelude; 4 | 5 | pub mod abuse_report_notification_recipient; 6 | pub mod abuse_user_report; 7 | pub mod access_token; 8 | pub mod ad; 9 | pub mod announcement; 10 | pub mod announcement_read; 11 | pub mod antenna; 12 | pub mod app; 13 | pub mod auth_session; 14 | pub mod avatar_decoration; 15 | pub mod blocking; 16 | pub mod bubble_game_record; 17 | pub mod channel; 18 | pub mod channel_favorite; 19 | pub mod channel_following; 20 | pub mod channel_note_pining; 21 | pub mod clip; 22 | pub mod clip_favorite; 23 | pub mod clip_note; 24 | pub mod drive_file; 25 | pub mod drive_folder; 26 | pub mod emoji; 27 | pub mod flash; 28 | pub mod flash_like; 29 | pub mod follow_request; 30 | pub mod following; 31 | pub mod gallery_like; 32 | pub mod gallery_post; 33 | pub mod hashtag; 34 | pub mod instance; 35 | pub mod messaging_message; 36 | pub mod meta; 37 | pub mod migrations; 38 | pub mod moderation_log; 39 | pub mod muting; 40 | pub mod note; 41 | pub mod note_favorite; 42 | pub mod note_reaction; 43 | pub mod note_thread_muting; 44 | pub mod note_unread; 45 | pub mod note_watching; 46 | pub mod page; 47 | pub mod page_like; 48 | pub mod password_reset_request; 49 | pub mod poll; 50 | pub mod poll_vote; 51 | pub mod promo_note; 52 | pub mod promo_read; 53 | pub mod registration_ticket; 54 | pub mod registry_item; 55 | pub mod relay; 56 | pub mod renote_muting; 57 | pub mod retention_aggregation; 58 | pub mod reversi_game; 59 | pub mod reversi_matching; 60 | pub mod role; 61 | pub mod role_assignment; 62 | pub mod sea_orm_active_enums; 63 | pub mod signin; 64 | pub mod sw_subscription; 65 | pub mod system_webhook; 66 | pub mod used_username; 67 | pub mod user; 68 | pub mod user_group; 69 | pub mod user_group_invitation; 70 | pub mod user_group_invite; 71 | pub mod user_group_joining; 72 | pub mod user_ip; 73 | pub mod user_keypair; 74 | pub mod user_list; 75 | pub mod user_list_favorite; 76 | pub mod user_list_membership; 77 | pub mod user_memo; 78 | pub mod user_note_pining; 79 | pub mod user_pending; 80 | pub mod user_profile; 81 | pub mod user_publickey; 82 | pub mod user_security_key; 83 | pub mod webhook; 84 | -------------------------------------------------------------------------------- /src/entities/moderation_log.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "moderation_log")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub r#type: String, 14 | #[sea_orm(column_type = "JsonBinary")] 15 | pub info: Json, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm( 21 | belongs_to = "super::user::Entity", 22 | from = "Column::UserId", 23 | to = "super::user::Column::Id", 24 | on_update = "NoAction", 25 | on_delete = "Cascade" 26 | )] 27 | User, 28 | } 29 | 30 | impl Related for Entity { 31 | fn to() -> RelationDef { 32 | Relation::User.def() 33 | } 34 | } 35 | 36 | impl ActiveModelBehavior for ActiveModel {} 37 | -------------------------------------------------------------------------------- /src/entities/muting.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "muting")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "muteeId")] 12 | pub mutee_id: String, 13 | #[sea_orm(column_name = "muterId")] 14 | pub muter_id: String, 15 | #[sea_orm(column_name = "expiresAt")] 16 | pub expires_at: Option, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::user::Entity", 23 | from = "Column::MuterId", 24 | to = "super::user::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | User2, 29 | #[sea_orm( 30 | belongs_to = "super::user::Entity", 31 | from = "Column::MuteeId", 32 | to = "super::user::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | User1, 37 | } 38 | 39 | impl ActiveModelBehavior for ActiveModel {} 40 | -------------------------------------------------------------------------------- /src/entities/note_favorite.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "note_favorite")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::note::Entity", 21 | from = "Column::NoteId", 22 | to = "super::note::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Note, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Note.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/note_reaction.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "note_reaction")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | pub reaction: String, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm( 21 | belongs_to = "super::note::Entity", 22 | from = "Column::NoteId", 23 | to = "super::note::Column::Id", 24 | on_update = "NoAction", 25 | on_delete = "Cascade" 26 | )] 27 | Note, 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::UserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User, 36 | } 37 | 38 | impl Related for Entity { 39 | fn to() -> RelationDef { 40 | Relation::Note.def() 41 | } 42 | } 43 | 44 | impl Related for Entity { 45 | fn to() -> RelationDef { 46 | Relation::User.def() 47 | } 48 | } 49 | 50 | impl ActiveModelBehavior for ActiveModel {} 51 | -------------------------------------------------------------------------------- /src/entities/note_thread_muting.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "note_thread_muting")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "threadId")] 14 | pub thread_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::UserId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User, 27 | } 28 | 29 | impl Related for Entity { 30 | fn to() -> RelationDef { 31 | Relation::User.def() 32 | } 33 | } 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/note_unread.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "note_unread")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | #[sea_orm(column_name = "noteUserId")] 16 | pub note_user_id: String, 17 | #[sea_orm(column_name = "isSpecified")] 18 | pub is_specified: bool, 19 | #[sea_orm(column_name = "isMentioned")] 20 | pub is_mentioned: bool, 21 | #[sea_orm(column_name = "noteChannelId")] 22 | pub note_channel_id: Option, 23 | } 24 | 25 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 26 | pub enum Relation { 27 | #[sea_orm( 28 | belongs_to = "super::note::Entity", 29 | from = "Column::NoteId", 30 | to = "super::note::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | Note, 35 | #[sea_orm( 36 | belongs_to = "super::user::Entity", 37 | from = "Column::UserId", 38 | to = "super::user::Column::Id", 39 | on_update = "NoAction", 40 | on_delete = "Cascade" 41 | )] 42 | User, 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::Note.def() 48 | } 49 | } 50 | 51 | impl Related for Entity { 52 | fn to() -> RelationDef { 53 | Relation::User.def() 54 | } 55 | } 56 | 57 | impl ActiveModelBehavior for ActiveModel {} 58 | -------------------------------------------------------------------------------- /src/entities/note_watching.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "note_watching")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "noteId")] 16 | pub note_id: String, 17 | #[sea_orm(column_name = "noteUserId")] 18 | pub note_user_id: String, 19 | } 20 | 21 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 22 | pub enum Relation { 23 | #[sea_orm( 24 | belongs_to = "super::note::Entity", 25 | from = "Column::NoteId", 26 | to = "super::note::Column::Id", 27 | on_update = "NoAction", 28 | on_delete = "Cascade" 29 | )] 30 | Note, 31 | #[sea_orm( 32 | belongs_to = "super::user::Entity", 33 | from = "Column::UserId", 34 | to = "super::user::Column::Id", 35 | on_update = "NoAction", 36 | on_delete = "Cascade" 37 | )] 38 | User, 39 | } 40 | 41 | impl Related for Entity { 42 | fn to() -> RelationDef { 43 | Relation::Note.def() 44 | } 45 | } 46 | 47 | impl Related for Entity { 48 | fn to() -> RelationDef { 49 | Relation::User.def() 50 | } 51 | } 52 | 53 | impl ActiveModelBehavior for ActiveModel {} 54 | -------------------------------------------------------------------------------- /src/entities/page.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::PageVisibilityEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "page")] 9 | pub struct Model { 10 | #[sea_orm(primary_key, auto_increment = false)] 11 | pub id: String, 12 | #[sea_orm(column_name = "updatedAt")] 13 | pub updated_at: DateTimeWithTimeZone, 14 | pub title: String, 15 | pub name: String, 16 | pub summary: Option, 17 | #[sea_orm(column_name = "alignCenter")] 18 | pub align_center: bool, 19 | pub font: String, 20 | #[sea_orm(column_name = "userId")] 21 | pub user_id: String, 22 | #[sea_orm(column_name = "eyeCatchingImageId")] 23 | pub eye_catching_image_id: Option, 24 | #[sea_orm(column_type = "JsonBinary")] 25 | pub content: Json, 26 | #[sea_orm(column_type = "JsonBinary")] 27 | pub variables: Json, 28 | pub visibility: PageVisibilityEnum, 29 | #[sea_orm(column_name = "visibleUserIds")] 30 | pub visible_user_ids: Vec, 31 | #[sea_orm(column_name = "likedCount")] 32 | pub liked_count: i32, 33 | #[sea_orm(column_name = "hideTitleWhenPinned")] 34 | pub hide_title_when_pinned: bool, 35 | pub script: String, 36 | } 37 | 38 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 39 | pub enum Relation { 40 | #[sea_orm( 41 | belongs_to = "super::drive_file::Entity", 42 | from = "Column::EyeCatchingImageId", 43 | to = "super::drive_file::Column::Id", 44 | on_update = "NoAction", 45 | on_delete = "Cascade" 46 | )] 47 | DriveFile, 48 | #[sea_orm(has_many = "super::page_like::Entity")] 49 | PageLike, 50 | #[sea_orm( 51 | belongs_to = "super::user::Entity", 52 | from = "Column::UserId", 53 | to = "super::user::Column::Id", 54 | on_update = "NoAction", 55 | on_delete = "Cascade" 56 | )] 57 | User, 58 | #[sea_orm(has_one = "super::user_profile::Entity")] 59 | UserProfile, 60 | } 61 | 62 | impl Related for Entity { 63 | fn to() -> RelationDef { 64 | Relation::DriveFile.def() 65 | } 66 | } 67 | 68 | impl Related for Entity { 69 | fn to() -> RelationDef { 70 | Relation::PageLike.def() 71 | } 72 | } 73 | 74 | impl Related for Entity { 75 | fn to() -> RelationDef { 76 | Relation::User.def() 77 | } 78 | } 79 | 80 | impl Related for Entity { 81 | fn to() -> RelationDef { 82 | Relation::UserProfile.def() 83 | } 84 | } 85 | 86 | impl ActiveModelBehavior for ActiveModel {} 87 | -------------------------------------------------------------------------------- /src/entities/page_like.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "page_like")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "pageId")] 14 | pub page_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::page::Entity", 21 | from = "Column::PageId", 22 | to = "super::page::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Page, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Page.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/password_reset_request.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "password_reset_request")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(unique)] 12 | pub token: String, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::UserId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User, 27 | } 28 | 29 | impl Related for Entity { 30 | fn to() -> RelationDef { 31 | Relation::User.def() 32 | } 33 | } 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/poll.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::PollNotevisibilityEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "poll")] 9 | pub struct Model { 10 | #[sea_orm(column_name = "noteId", primary_key, auto_increment = false)] 11 | pub note_id: String, 12 | #[sea_orm(column_name = "expiresAt")] 13 | pub expires_at: Option, 14 | pub multiple: bool, 15 | pub choices: Vec, 16 | pub votes: Vec, 17 | #[sea_orm(column_name = "noteVisibility")] 18 | pub note_visibility: PollNotevisibilityEnum, 19 | #[sea_orm(column_name = "userId")] 20 | pub user_id: String, 21 | #[sea_orm(column_name = "userHost")] 22 | pub user_host: Option, 23 | #[sea_orm(column_name = "channelId")] 24 | pub channel_id: Option, 25 | } 26 | 27 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 28 | pub enum Relation { 29 | #[sea_orm( 30 | belongs_to = "super::note::Entity", 31 | from = "Column::NoteId", 32 | to = "super::note::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | Note, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::Note.def() 42 | } 43 | } 44 | 45 | impl ActiveModelBehavior for ActiveModel {} 46 | -------------------------------------------------------------------------------- /src/entities/poll_vote.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "poll_vote")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | pub choice: i32, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm( 21 | belongs_to = "super::note::Entity", 22 | from = "Column::NoteId", 23 | to = "super::note::Column::Id", 24 | on_update = "NoAction", 25 | on_delete = "Cascade" 26 | )] 27 | Note, 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::UserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User, 36 | } 37 | 38 | impl Related for Entity { 39 | fn to() -> RelationDef { 40 | Relation::Note.def() 41 | } 42 | } 43 | 44 | impl Related for Entity { 45 | fn to() -> RelationDef { 46 | Relation::User.def() 47 | } 48 | } 49 | 50 | impl ActiveModelBehavior for ActiveModel {} 51 | -------------------------------------------------------------------------------- /src/entities/prelude.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | #![allow(unused_imports)] 4 | 5 | pub use super::abuse_report_notification_recipient::Entity as AbuseReportNotificationRecipient; 6 | pub use super::abuse_user_report::Entity as AbuseUserReport; 7 | pub use super::access_token::Entity as AccessToken; 8 | pub use super::ad::Entity as Ad; 9 | pub use super::announcement::Entity as Announcement; 10 | pub use super::announcement_read::Entity as AnnouncementRead; 11 | pub use super::antenna::Entity as Antenna; 12 | pub use super::app::Entity as App; 13 | pub use super::auth_session::Entity as AuthSession; 14 | pub use super::avatar_decoration::Entity as AvatarDecoration; 15 | pub use super::blocking::Entity as Blocking; 16 | pub use super::bubble_game_record::Entity as BubbleGameRecord; 17 | pub use super::channel::Entity as Channel; 18 | pub use super::channel_favorite::Entity as ChannelFavorite; 19 | pub use super::channel_following::Entity as ChannelFollowing; 20 | pub use super::channel_note_pining::Entity as ChannelNotePining; 21 | pub use super::clip::Entity as Clip; 22 | pub use super::clip_favorite::Entity as ClipFavorite; 23 | pub use super::clip_note::Entity as ClipNote; 24 | pub use super::drive_file::Entity as DriveFile; 25 | pub use super::drive_folder::Entity as DriveFolder; 26 | pub use super::emoji::Entity as Emoji; 27 | pub use super::flash::Entity as Flash; 28 | pub use super::flash_like::Entity as FlashLike; 29 | pub use super::follow_request::Entity as FollowRequest; 30 | pub use super::following::Entity as Following; 31 | pub use super::gallery_like::Entity as GalleryLike; 32 | pub use super::gallery_post::Entity as GalleryPost; 33 | pub use super::hashtag::Entity as Hashtag; 34 | pub use super::instance::Entity as Instance; 35 | pub use super::messaging_message::Entity as MessagingMessage; 36 | pub use super::meta::Entity as Meta; 37 | pub use super::migrations::Entity as Migrations; 38 | pub use super::moderation_log::Entity as ModerationLog; 39 | pub use super::muting::Entity as Muting; 40 | pub use super::note::Entity as Note; 41 | pub use super::note_favorite::Entity as NoteFavorite; 42 | pub use super::note_reaction::Entity as NoteReaction; 43 | pub use super::note_thread_muting::Entity as NoteThreadMuting; 44 | pub use super::note_unread::Entity as NoteUnread; 45 | pub use super::note_watching::Entity as NoteWatching; 46 | pub use super::page::Entity as Page; 47 | pub use super::page_like::Entity as PageLike; 48 | pub use super::password_reset_request::Entity as PasswordResetRequest; 49 | pub use super::poll::Entity as Poll; 50 | pub use super::poll_vote::Entity as PollVote; 51 | pub use super::promo_note::Entity as PromoNote; 52 | pub use super::promo_read::Entity as PromoRead; 53 | pub use super::registration_ticket::Entity as RegistrationTicket; 54 | pub use super::registry_item::Entity as RegistryItem; 55 | pub use super::relay::Entity as Relay; 56 | pub use super::renote_muting::Entity as RenoteMuting; 57 | pub use super::retention_aggregation::Entity as RetentionAggregation; 58 | pub use super::reversi_game::Entity as ReversiGame; 59 | pub use super::reversi_matching::Entity as ReversiMatching; 60 | pub use super::role::Entity as Role; 61 | pub use super::role_assignment::Entity as RoleAssignment; 62 | pub use super::signin::Entity as Signin; 63 | pub use super::sw_subscription::Entity as SwSubscription; 64 | pub use super::system_webhook::Entity as SystemWebhook; 65 | pub use super::used_username::Entity as UsedUsername; 66 | pub use super::user::Entity as User; 67 | pub use super::user_group::Entity as UserGroup; 68 | pub use super::user_group_invitation::Entity as UserGroupInvitation; 69 | pub use super::user_group_invite::Entity as UserGroupInvite; 70 | pub use super::user_group_joining::Entity as UserGroupJoining; 71 | pub use super::user_ip::Entity as UserIp; 72 | pub use super::user_keypair::Entity as UserKeypair; 73 | pub use super::user_list::Entity as UserList; 74 | pub use super::user_list_favorite::Entity as UserListFavorite; 75 | pub use super::user_list_membership::Entity as UserListMembership; 76 | pub use super::user_memo::Entity as UserMemo; 77 | pub use super::user_note_pining::Entity as UserNotePining; 78 | pub use super::user_pending::Entity as UserPending; 79 | pub use super::user_profile::Entity as UserProfile; 80 | pub use super::user_publickey::Entity as UserPublickey; 81 | pub use super::user_security_key::Entity as UserSecurityKey; 82 | pub use super::webhook::Entity as Webhook; 83 | -------------------------------------------------------------------------------- /src/entities/promo_note.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "promo_note")] 8 | pub struct Model { 9 | #[sea_orm(column_name = "noteId", primary_key, auto_increment = false)] 10 | pub note_id: String, 11 | #[sea_orm(column_name = "expiresAt")] 12 | pub expires_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::note::Entity", 21 | from = "Column::NoteId", 22 | to = "super::note::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Note, 27 | } 28 | 29 | impl Related for Entity { 30 | fn to() -> RelationDef { 31 | Relation::Note.def() 32 | } 33 | } 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/promo_read.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "promo_read")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::note::Entity", 21 | from = "Column::NoteId", 22 | to = "super::note::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Note, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Note.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/registration_ticket.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "registration_ticket")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(unique)] 12 | pub code: String, 13 | #[sea_orm(column_name = "expiresAt")] 14 | pub expires_at: Option, 15 | #[sea_orm(column_name = "usedAt")] 16 | pub used_at: Option, 17 | #[sea_orm(column_name = "pendingUserId")] 18 | pub pending_user_id: Option, 19 | #[sea_orm(column_name = "createdById")] 20 | pub created_by_id: Option, 21 | #[sea_orm(column_name = "usedById", unique)] 22 | pub used_by_id: Option, 23 | } 24 | 25 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 26 | pub enum Relation { 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UsedById", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User2, 35 | #[sea_orm( 36 | belongs_to = "super::user::Entity", 37 | from = "Column::CreatedById", 38 | to = "super::user::Column::Id", 39 | on_update = "NoAction", 40 | on_delete = "Cascade" 41 | )] 42 | User1, 43 | } 44 | 45 | impl ActiveModelBehavior for ActiveModel {} 46 | -------------------------------------------------------------------------------- /src/entities/registry_item.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "registry_item")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "updatedAt")] 12 | pub updated_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | pub key: String, 16 | pub scope: Vec, 17 | pub domain: Option, 18 | #[sea_orm(column_type = "JsonBinary", nullable)] 19 | pub value: Option, 20 | } 21 | 22 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 23 | pub enum Relation { 24 | #[sea_orm( 25 | belongs_to = "super::user::Entity", 26 | from = "Column::UserId", 27 | to = "super::user::Column::Id", 28 | on_update = "NoAction", 29 | on_delete = "Cascade" 30 | )] 31 | User, 32 | } 33 | 34 | impl Related for Entity { 35 | fn to() -> RelationDef { 36 | Relation::User.def() 37 | } 38 | } 39 | 40 | impl ActiveModelBehavior for ActiveModel {} 41 | -------------------------------------------------------------------------------- /src/entities/relay.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::RelayStatusEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "relay")] 9 | pub struct Model { 10 | #[sea_orm(primary_key, auto_increment = false)] 11 | pub id: String, 12 | #[sea_orm(unique)] 13 | pub inbox: String, 14 | pub status: RelayStatusEnum, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation {} 19 | 20 | impl ActiveModelBehavior for ActiveModel {} 21 | -------------------------------------------------------------------------------- /src/entities/renote_muting.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "renote_muting")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "muteeId")] 12 | pub mutee_id: String, 13 | #[sea_orm(column_name = "muterId")] 14 | pub muter_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::MuterId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User2, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::MuteeId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User1, 35 | } 36 | 37 | impl ActiveModelBehavior for ActiveModel {} 38 | -------------------------------------------------------------------------------- /src/entities/retention_aggregation.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "retention_aggregation")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userIds")] 14 | pub user_ids: Vec, 15 | #[sea_orm(column_type = "JsonBinary")] 16 | pub data: Json, 17 | #[sea_orm(column_name = "updatedAt")] 18 | pub updated_at: DateTimeWithTimeZone, 19 | #[sea_orm(column_name = "usersCount")] 20 | pub users_count: i32, 21 | #[sea_orm(column_name = "dateKey", unique)] 22 | pub date_key: String, 23 | } 24 | 25 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 26 | pub enum Relation {} 27 | 28 | impl ActiveModelBehavior for ActiveModel {} 29 | -------------------------------------------------------------------------------- /src/entities/reversi_game.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "reversi_game")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "startedAt")] 12 | pub started_at: Option, 13 | #[sea_orm(column_name = "user1Id")] 14 | pub user1_id: String, 15 | #[sea_orm(column_name = "user2Id")] 16 | pub user2_id: String, 17 | #[sea_orm(column_name = "user1Ready")] 18 | pub user1_ready: bool, 19 | #[sea_orm(column_name = "user2Ready")] 20 | pub user2_ready: bool, 21 | pub black: Option, 22 | #[sea_orm(column_name = "isStarted")] 23 | pub is_started: bool, 24 | #[sea_orm(column_name = "isEnded")] 25 | pub is_ended: bool, 26 | #[sea_orm(column_name = "winnerId")] 27 | pub winner_id: Option, 28 | #[sea_orm(column_name = "surrenderedUserId")] 29 | pub surrendered_user_id: Option, 30 | #[sea_orm(column_type = "JsonBinary")] 31 | pub logs: Json, 32 | pub map: Vec, 33 | pub bw: String, 34 | #[sea_orm(column_name = "isLlotheo")] 35 | pub is_llotheo: bool, 36 | #[sea_orm(column_name = "canPutEverywhere")] 37 | pub can_put_everywhere: bool, 38 | #[sea_orm(column_name = "loopedBoard")] 39 | pub looped_board: bool, 40 | #[sea_orm(column_type = "JsonBinary", nullable)] 41 | pub form1: Option, 42 | #[sea_orm(column_type = "JsonBinary", nullable)] 43 | pub form2: Option, 44 | pub crc32: Option, 45 | #[sea_orm(column_name = "timeoutUserId")] 46 | pub timeout_user_id: Option, 47 | #[sea_orm(column_name = "endedAt")] 48 | pub ended_at: Option, 49 | #[sea_orm(column_name = "timeLimitForEachTurn")] 50 | pub time_limit_for_each_turn: i16, 51 | #[sea_orm(column_name = "noIrregularRules")] 52 | pub no_irregular_rules: bool, 53 | } 54 | 55 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 56 | pub enum Relation { 57 | #[sea_orm( 58 | belongs_to = "super::user::Entity", 59 | from = "Column::User2Id", 60 | to = "super::user::Column::Id", 61 | on_update = "NoAction", 62 | on_delete = "Cascade" 63 | )] 64 | User2, 65 | #[sea_orm( 66 | belongs_to = "super::user::Entity", 67 | from = "Column::User1Id", 68 | to = "super::user::Column::Id", 69 | on_update = "NoAction", 70 | on_delete = "Cascade" 71 | )] 72 | User1, 73 | } 74 | 75 | impl ActiveModelBehavior for ActiveModel {} 76 | -------------------------------------------------------------------------------- /src/entities/reversi_matching.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "reversi_matching")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "parentId")] 12 | pub parent_id: String, 13 | #[sea_orm(column_name = "childId")] 14 | pub child_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::ParentId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User2, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::ChildId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User1, 35 | } 36 | 37 | impl ActiveModelBehavior for ActiveModel {} 38 | -------------------------------------------------------------------------------- /src/entities/role.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::RoleTargetEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 8 | #[sea_orm(table_name = "role")] 9 | pub struct Model { 10 | #[sea_orm(primary_key, auto_increment = false)] 11 | pub id: String, 12 | #[sea_orm(column_name = "updatedAt")] 13 | pub updated_at: DateTimeWithTimeZone, 14 | pub name: String, 15 | pub description: String, 16 | #[sea_orm(column_name = "isPublic")] 17 | pub is_public: bool, 18 | #[sea_orm(column_name = "isModerator")] 19 | pub is_moderator: bool, 20 | #[sea_orm(column_name = "isAdministrator")] 21 | pub is_administrator: bool, 22 | #[sea_orm(column_type = "JsonBinary")] 23 | pub policies: Json, 24 | pub color: Option, 25 | #[sea_orm(column_name = "canEditMembersByModerator")] 26 | pub can_edit_members_by_moderator: bool, 27 | #[sea_orm(column_name = "lastUsedAt")] 28 | pub last_used_at: DateTimeWithTimeZone, 29 | pub target: RoleTargetEnum, 30 | #[sea_orm(column_name = "condFormula", column_type = "JsonBinary")] 31 | pub cond_formula: Json, 32 | #[sea_orm(column_name = "iconUrl")] 33 | pub icon_url: Option, 34 | #[sea_orm(column_name = "asBadge")] 35 | pub as_badge: bool, 36 | #[sea_orm(column_name = "displayOrder")] 37 | pub display_order: i32, 38 | #[sea_orm(column_name = "isExplorable")] 39 | pub is_explorable: bool, 40 | } 41 | 42 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 43 | pub enum Relation { 44 | #[sea_orm(has_many = "super::role_assignment::Entity")] 45 | RoleAssignment, 46 | } 47 | 48 | impl Related for Entity { 49 | fn to() -> RelationDef { 50 | Relation::RoleAssignment.def() 51 | } 52 | } 53 | 54 | impl ActiveModelBehavior for ActiveModel {} 55 | -------------------------------------------------------------------------------- /src/entities/role_assignment.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "role_assignment")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "roleId")] 14 | pub role_id: String, 15 | #[sea_orm(column_name = "expiresAt")] 16 | pub expires_at: Option, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::role::Entity", 23 | from = "Column::RoleId", 24 | to = "super::role::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | Role, 29 | #[sea_orm( 30 | belongs_to = "super::user::Entity", 31 | from = "Column::UserId", 32 | to = "super::user::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | User, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::Role.def() 42 | } 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::User.def() 48 | } 49 | } 50 | 51 | impl ActiveModelBehavior for ActiveModel {} 52 | -------------------------------------------------------------------------------- /src/entities/sea_orm_active_enums.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use clap::ValueEnum; 4 | use sea_orm::entity::prelude::*; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | #[derive( 8 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 9 | )] 10 | #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")] 11 | pub enum AntennaSrcEnum { 12 | #[sea_orm(string_value = "home")] 13 | Home, 14 | #[sea_orm(string_value = "all")] 15 | All, 16 | #[sea_orm(string_value = "users")] 17 | Users, 18 | #[sea_orm(string_value = "list")] 19 | List, 20 | #[sea_orm(string_value = "users_blacklist")] 21 | UsersBlacklist, 22 | } 23 | #[derive( 24 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 25 | )] 26 | #[sea_orm( 27 | rs_type = "String", 28 | db_type = "Enum", 29 | enum_name = "instance_suspensionstate_enum" 30 | )] 31 | pub enum InstanceSuspensionstateEnum { 32 | #[sea_orm(string_value = "none")] 33 | None, 34 | #[sea_orm(string_value = "manuallySuspended")] 35 | ManuallySuspended, 36 | #[sea_orm(string_value = "goneSuspended")] 37 | GoneSuspended, 38 | #[sea_orm(string_value = "autoSuspendedForNotResponding")] 39 | AutoSuspendedForNotResponding, 40 | } 41 | #[derive( 42 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 43 | )] 44 | #[sea_orm( 45 | rs_type = "String", 46 | db_type = "Enum", 47 | enum_name = "meta_sensitivemediadetection_enum" 48 | )] 49 | pub enum MetaSensitivemediadetectionEnum { 50 | #[sea_orm(string_value = "none")] 51 | None, 52 | #[sea_orm(string_value = "all")] 53 | All, 54 | #[sea_orm(string_value = "local")] 55 | Local, 56 | #[sea_orm(string_value = "remote")] 57 | Remote, 58 | } 59 | #[derive( 60 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 61 | )] 62 | #[sea_orm( 63 | rs_type = "String", 64 | db_type = "Enum", 65 | enum_name = "meta_sensitivemediadetectionsensitivity_enum" 66 | )] 67 | pub enum MetaSensitivemediadetectionsensitivityEnum { 68 | #[sea_orm(string_value = "medium")] 69 | Medium, 70 | #[sea_orm(string_value = "low")] 71 | Low, 72 | #[sea_orm(string_value = "high")] 73 | High, 74 | #[sea_orm(string_value = "veryLow")] 75 | VeryLow, 76 | #[sea_orm(string_value = "veryHigh")] 77 | VeryHigh, 78 | } 79 | #[derive( 80 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 81 | )] 82 | #[sea_orm( 83 | rs_type = "String", 84 | db_type = "Enum", 85 | enum_name = "note_visibility_enum" 86 | )] 87 | pub enum NoteVisibilityEnum { 88 | #[sea_orm(string_value = "public")] 89 | Public, 90 | #[sea_orm(string_value = "home")] 91 | Home, 92 | #[sea_orm(string_value = "followers")] 93 | Followers, 94 | #[sea_orm(string_value = "specified")] 95 | Specified, 96 | } 97 | #[derive( 98 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 99 | )] 100 | #[sea_orm( 101 | rs_type = "String", 102 | db_type = "Enum", 103 | enum_name = "page_visibility_enum" 104 | )] 105 | pub enum PageVisibilityEnum { 106 | #[sea_orm(string_value = "public")] 107 | Public, 108 | #[sea_orm(string_value = "followers")] 109 | Followers, 110 | #[sea_orm(string_value = "specified")] 111 | Specified, 112 | } 113 | #[derive( 114 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 115 | )] 116 | #[sea_orm( 117 | rs_type = "String", 118 | db_type = "Enum", 119 | enum_name = "poll_notevisibility_enum" 120 | )] 121 | pub enum PollNotevisibilityEnum { 122 | #[sea_orm(string_value = "public")] 123 | Public, 124 | #[sea_orm(string_value = "home")] 125 | Home, 126 | #[sea_orm(string_value = "followers")] 127 | Followers, 128 | #[sea_orm(string_value = "specified")] 129 | Specified, 130 | } 131 | #[derive( 132 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 133 | )] 134 | #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")] 135 | pub enum RelayStatusEnum { 136 | #[sea_orm(string_value = "requesting")] 137 | Requesting, 138 | #[sea_orm(string_value = "accepted")] 139 | Accepted, 140 | #[sea_orm(string_value = "rejected")] 141 | Rejected, 142 | } 143 | #[derive( 144 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 145 | )] 146 | #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "role_target_enum")] 147 | pub enum RoleTargetEnum { 148 | #[sea_orm(string_value = "manual")] 149 | Manual, 150 | #[sea_orm(string_value = "conditional")] 151 | Conditional, 152 | } 153 | #[derive( 154 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 155 | )] 156 | #[sea_orm( 157 | rs_type = "String", 158 | db_type = "Enum", 159 | enum_name = "user_profile_followersVisibility_enum" 160 | )] 161 | pub enum UserProfileFollowersVisibilityEnum { 162 | #[sea_orm(string_value = "public")] 163 | Public, 164 | #[sea_orm(string_value = "followers")] 165 | Followers, 166 | #[sea_orm(string_value = "private")] 167 | Private, 168 | } 169 | #[derive( 170 | Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, ValueEnum, 171 | )] 172 | #[sea_orm( 173 | rs_type = "String", 174 | db_type = "Enum", 175 | enum_name = "user_profile_followingvisibility_enum" 176 | )] 177 | pub enum UserProfileFollowingvisibilityEnum { 178 | #[sea_orm(string_value = "public")] 179 | Public, 180 | #[sea_orm(string_value = "followers")] 181 | Followers, 182 | #[sea_orm(string_value = "private")] 183 | Private, 184 | } 185 | -------------------------------------------------------------------------------- /src/entities/signin.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "signin")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub ip: String, 14 | #[sea_orm(column_type = "JsonBinary")] 15 | pub headers: Json, 16 | pub success: bool, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::user::Entity", 23 | from = "Column::UserId", 24 | to = "super::user::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | User, 29 | } 30 | 31 | impl Related for Entity { 32 | fn to() -> RelationDef { 33 | Relation::User.def() 34 | } 35 | } 36 | 37 | impl ActiveModelBehavior for ActiveModel {} 38 | -------------------------------------------------------------------------------- /src/entities/sw_subscription.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "sw_subscription")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub endpoint: String, 14 | pub auth: String, 15 | pub publickey: String, 16 | #[sea_orm(column_name = "sendReadMessage")] 17 | pub send_read_message: bool, 18 | } 19 | 20 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 21 | pub enum Relation { 22 | #[sea_orm( 23 | belongs_to = "super::user::Entity", 24 | from = "Column::UserId", 25 | to = "super::user::Column::Id", 26 | on_update = "NoAction", 27 | on_delete = "Cascade" 28 | )] 29 | User, 30 | } 31 | 32 | impl Related for Entity { 33 | fn to() -> RelationDef { 34 | Relation::User.def() 35 | } 36 | } 37 | 38 | impl ActiveModelBehavior for ActiveModel {} 39 | -------------------------------------------------------------------------------- /src/entities/system_webhook.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "system_webhook")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "isActive")] 12 | pub is_active: bool, 13 | #[sea_orm(column_name = "updatedAt")] 14 | pub updated_at: DateTimeWithTimeZone, 15 | #[sea_orm(column_name = "latestSentAt")] 16 | pub latest_sent_at: Option, 17 | #[sea_orm(column_name = "latestStatus")] 18 | pub latest_status: Option, 19 | pub name: String, 20 | pub on: Vec, 21 | pub url: String, 22 | pub secret: String, 23 | } 24 | 25 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 26 | pub enum Relation { 27 | #[sea_orm(has_many = "super::abuse_report_notification_recipient::Entity")] 28 | AbuseReportNotificationRecipient, 29 | } 30 | 31 | impl Related for Entity { 32 | fn to() -> RelationDef { 33 | Relation::AbuseReportNotificationRecipient.def() 34 | } 35 | } 36 | 37 | impl ActiveModelBehavior for ActiveModel {} 38 | -------------------------------------------------------------------------------- /src/entities/used_username.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "used_username")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub username: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | } 14 | 15 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 16 | pub enum Relation {} 17 | 18 | impl ActiveModelBehavior for ActiveModel {} 19 | -------------------------------------------------------------------------------- /src/entities/user_group.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_group")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | pub name: String, 14 | #[sea_orm(column_name = "userId")] 15 | pub user_id: String, 16 | #[sea_orm(column_name = "isPrivate")] 17 | pub is_private: bool, 18 | } 19 | 20 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 21 | pub enum Relation { 22 | #[sea_orm(has_many = "super::messaging_message::Entity")] 23 | MessagingMessage, 24 | #[sea_orm( 25 | belongs_to = "super::user::Entity", 26 | from = "Column::UserId", 27 | to = "super::user::Column::Id", 28 | on_update = "NoAction", 29 | on_delete = "Cascade" 30 | )] 31 | User, 32 | #[sea_orm(has_many = "super::user_group_invitation::Entity")] 33 | UserGroupInvitation, 34 | #[sea_orm(has_many = "super::user_group_invite::Entity")] 35 | UserGroupInvite, 36 | #[sea_orm(has_many = "super::user_group_joining::Entity")] 37 | UserGroupJoining, 38 | } 39 | 40 | impl Related for Entity { 41 | fn to() -> RelationDef { 42 | Relation::MessagingMessage.def() 43 | } 44 | } 45 | 46 | impl Related for Entity { 47 | fn to() -> RelationDef { 48 | Relation::User.def() 49 | } 50 | } 51 | 52 | impl Related for Entity { 53 | fn to() -> RelationDef { 54 | Relation::UserGroupInvitation.def() 55 | } 56 | } 57 | 58 | impl Related for Entity { 59 | fn to() -> RelationDef { 60 | Relation::UserGroupInvite.def() 61 | } 62 | } 63 | 64 | impl Related for Entity { 65 | fn to() -> RelationDef { 66 | Relation::UserGroupJoining.def() 67 | } 68 | } 69 | 70 | impl ActiveModelBehavior for ActiveModel {} 71 | -------------------------------------------------------------------------------- /src/entities/user_group_invitation.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_group_invitation")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "userGroupId")] 16 | pub user_group_id: String, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::user::Entity", 23 | from = "Column::UserId", 24 | to = "super::user::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | User, 29 | #[sea_orm( 30 | belongs_to = "super::user_group::Entity", 31 | from = "Column::UserGroupId", 32 | to = "super::user_group::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | UserGroup, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::User.def() 42 | } 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::UserGroup.def() 48 | } 49 | } 50 | 51 | impl ActiveModelBehavior for ActiveModel {} 52 | -------------------------------------------------------------------------------- /src/entities/user_group_invite.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_group_invite")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "userGroupId")] 16 | pub user_group_id: String, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::user::Entity", 23 | from = "Column::UserId", 24 | to = "super::user::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | User, 29 | #[sea_orm( 30 | belongs_to = "super::user_group::Entity", 31 | from = "Column::UserGroupId", 32 | to = "super::user_group::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | UserGroup, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::User.def() 42 | } 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::UserGroup.def() 48 | } 49 | } 50 | 51 | impl ActiveModelBehavior for ActiveModel {} 52 | -------------------------------------------------------------------------------- /src/entities/user_group_joining.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_group_joining")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | #[sea_orm(column_name = "userGroupId")] 16 | pub user_group_id: String, 17 | } 18 | 19 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 20 | pub enum Relation { 21 | #[sea_orm( 22 | belongs_to = "super::user::Entity", 23 | from = "Column::UserId", 24 | to = "super::user::Column::Id", 25 | on_update = "NoAction", 26 | on_delete = "Cascade" 27 | )] 28 | User, 29 | #[sea_orm( 30 | belongs_to = "super::user_group::Entity", 31 | from = "Column::UserGroupId", 32 | to = "super::user_group::Column::Id", 33 | on_update = "NoAction", 34 | on_delete = "Cascade" 35 | )] 36 | UserGroup, 37 | } 38 | 39 | impl Related for Entity { 40 | fn to() -> RelationDef { 41 | Relation::User.def() 42 | } 43 | } 44 | 45 | impl Related for Entity { 46 | fn to() -> RelationDef { 47 | Relation::UserGroup.def() 48 | } 49 | } 50 | 51 | impl ActiveModelBehavior for ActiveModel {} 52 | -------------------------------------------------------------------------------- /src/entities/user_ip.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_ip")] 8 | pub struct Model { 9 | #[sea_orm(primary_key)] 10 | pub id: i32, 11 | #[sea_orm(column_name = "createdAt")] 12 | pub created_at: DateTimeWithTimeZone, 13 | #[sea_orm(column_name = "userId")] 14 | pub user_id: String, 15 | pub ip: String, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation {} 20 | 21 | impl ActiveModelBehavior for ActiveModel {} 22 | -------------------------------------------------------------------------------- /src/entities/user_keypair.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_keypair")] 8 | pub struct Model { 9 | #[sea_orm(column_name = "userId", primary_key, auto_increment = false)] 10 | pub user_id: String, 11 | #[sea_orm(column_name = "publicKey")] 12 | pub public_key: String, 13 | #[sea_orm(column_name = "privateKey")] 14 | pub private_key: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::UserId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User, 27 | } 28 | 29 | impl Related for Entity { 30 | fn to() -> RelationDef { 31 | Relation::User.def() 32 | } 33 | } 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/user_list.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_list")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub name: String, 14 | #[sea_orm(column_name = "isPublic")] 15 | pub is_public: bool, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm(has_many = "super::antenna::Entity")] 21 | Antenna, 22 | #[sea_orm( 23 | belongs_to = "super::user::Entity", 24 | from = "Column::UserId", 25 | to = "super::user::Column::Id", 26 | on_update = "NoAction", 27 | on_delete = "Cascade" 28 | )] 29 | User, 30 | #[sea_orm(has_many = "super::user_list_favorite::Entity")] 31 | UserListFavorite, 32 | #[sea_orm(has_many = "super::user_list_membership::Entity")] 33 | UserListMembership, 34 | } 35 | 36 | impl Related for Entity { 37 | fn to() -> RelationDef { 38 | Relation::Antenna.def() 39 | } 40 | } 41 | 42 | impl Related for Entity { 43 | fn to() -> RelationDef { 44 | Relation::User.def() 45 | } 46 | } 47 | 48 | impl Related for Entity { 49 | fn to() -> RelationDef { 50 | Relation::UserListFavorite.def() 51 | } 52 | } 53 | 54 | impl Related for Entity { 55 | fn to() -> RelationDef { 56 | Relation::UserListMembership.def() 57 | } 58 | } 59 | 60 | impl ActiveModelBehavior for ActiveModel {} 61 | -------------------------------------------------------------------------------- /src/entities/user_list_favorite.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_list_favorite")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "userListId")] 14 | pub user_list_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::UserId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User, 27 | #[sea_orm( 28 | belongs_to = "super::user_list::Entity", 29 | from = "Column::UserListId", 30 | to = "super::user_list::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | UserList, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::User.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::UserList.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/user_list_membership.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_list_membership")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "userListId")] 14 | pub user_list_id: String, 15 | #[sea_orm(column_name = "withReplies")] 16 | pub with_replies: bool, 17 | #[sea_orm(column_name = "userListUserId")] 18 | pub user_list_user_id: String, 19 | } 20 | 21 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 22 | pub enum Relation { 23 | #[sea_orm( 24 | belongs_to = "super::user::Entity", 25 | from = "Column::UserId", 26 | to = "super::user::Column::Id", 27 | on_update = "NoAction", 28 | on_delete = "Cascade" 29 | )] 30 | User, 31 | #[sea_orm( 32 | belongs_to = "super::user_list::Entity", 33 | from = "Column::UserListId", 34 | to = "super::user_list::Column::Id", 35 | on_update = "NoAction", 36 | on_delete = "Cascade" 37 | )] 38 | UserList, 39 | } 40 | 41 | impl Related for Entity { 42 | fn to() -> RelationDef { 43 | Relation::User.def() 44 | } 45 | } 46 | 47 | impl Related for Entity { 48 | fn to() -> RelationDef { 49 | Relation::UserList.def() 50 | } 51 | } 52 | 53 | impl ActiveModelBehavior for ActiveModel {} 54 | -------------------------------------------------------------------------------- /src/entities/user_memo.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_memo")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "targetUserId")] 14 | pub target_user_id: String, 15 | pub memo: String, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation { 20 | #[sea_orm( 21 | belongs_to = "super::user::Entity", 22 | from = "Column::UserId", 23 | to = "super::user::Column::Id", 24 | on_update = "NoAction", 25 | on_delete = "Cascade" 26 | )] 27 | User2, 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::TargetUserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User1, 36 | } 37 | 38 | impl ActiveModelBehavior for ActiveModel {} 39 | -------------------------------------------------------------------------------- /src/entities/user_note_pining.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_note_pining")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "noteId")] 14 | pub note_id: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::note::Entity", 21 | from = "Column::NoteId", 22 | to = "super::note::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | Note, 27 | #[sea_orm( 28 | belongs_to = "super::user::Entity", 29 | from = "Column::UserId", 30 | to = "super::user::Column::Id", 31 | on_update = "NoAction", 32 | on_delete = "Cascade" 33 | )] 34 | User, 35 | } 36 | 37 | impl Related for Entity { 38 | fn to() -> RelationDef { 39 | Relation::Note.def() 40 | } 41 | } 42 | 43 | impl Related for Entity { 44 | fn to() -> RelationDef { 45 | Relation::User.def() 46 | } 47 | } 48 | 49 | impl ActiveModelBehavior for ActiveModel {} 50 | -------------------------------------------------------------------------------- /src/entities/user_pending.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_pending")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(unique)] 12 | pub code: String, 13 | pub username: String, 14 | pub email: String, 15 | pub password: String, 16 | } 17 | 18 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 19 | pub enum Relation {} 20 | 21 | impl ActiveModelBehavior for ActiveModel {} 22 | -------------------------------------------------------------------------------- /src/entities/user_profile.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use super::sea_orm_active_enums::UserProfileFollowersVisibilityEnum; 4 | use super::sea_orm_active_enums::UserProfileFollowingvisibilityEnum; 5 | use sea_orm::entity::prelude::*; 6 | use serde::{Deserialize, Serialize}; 7 | 8 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 9 | #[sea_orm(table_name = "user_profile")] 10 | pub struct Model { 11 | #[sea_orm(column_name = "userId", primary_key, auto_increment = false)] 12 | pub user_id: String, 13 | pub location: Option, 14 | pub birthday: Option, 15 | pub description: Option, 16 | #[sea_orm(column_type = "JsonBinary")] 17 | pub fields: Json, 18 | pub url: Option, 19 | pub email: Option, 20 | #[sea_orm(column_name = "emailVerifyCode")] 21 | pub email_verify_code: Option, 22 | #[sea_orm(column_name = "emailVerified")] 23 | pub email_verified: bool, 24 | #[sea_orm(column_name = "twoFactorTempSecret")] 25 | pub two_factor_temp_secret: Option, 26 | #[sea_orm(column_name = "twoFactorSecret")] 27 | pub two_factor_secret: Option, 28 | #[sea_orm(column_name = "twoFactorEnabled")] 29 | pub two_factor_enabled: bool, 30 | pub password: Option, 31 | #[sea_orm(column_name = "clientData", column_type = "JsonBinary")] 32 | pub client_data: Json, 33 | #[sea_orm(column_name = "autoAcceptFollowed")] 34 | pub auto_accept_followed: bool, 35 | #[sea_orm(column_name = "alwaysMarkNsfw")] 36 | pub always_mark_nsfw: bool, 37 | #[sea_orm(column_name = "carefulBot")] 38 | pub careful_bot: bool, 39 | #[sea_orm(column_name = "userHost")] 40 | pub user_host: Option, 41 | #[sea_orm(column_name = "securityKeysAvailable")] 42 | pub security_keys_available: bool, 43 | #[sea_orm(column_name = "usePasswordLessLogin")] 44 | pub use_password_less_login: bool, 45 | #[sea_orm(column_name = "pinnedPageId", unique)] 46 | pub pinned_page_id: Option, 47 | #[sea_orm(column_type = "JsonBinary")] 48 | pub room: Json, 49 | #[sea_orm(column_name = "injectFeaturedNote")] 50 | pub inject_featured_note: bool, 51 | #[sea_orm(column_name = "enableWordMute")] 52 | pub enable_word_mute: bool, 53 | #[sea_orm(column_name = "mutedWords", column_type = "JsonBinary")] 54 | pub muted_words: Json, 55 | #[sea_orm(column_name = "noCrawle")] 56 | pub no_crawle: bool, 57 | #[sea_orm(column_name = "receiveAnnouncementEmail")] 58 | pub receive_announcement_email: bool, 59 | #[sea_orm(column_name = "emailNotificationTypes", column_type = "JsonBinary")] 60 | pub email_notification_types: Json, 61 | pub lang: Option, 62 | #[sea_orm(column_name = "mutedInstances", column_type = "JsonBinary")] 63 | pub muted_instances: Json, 64 | #[sea_orm(column_name = "publicReactions")] 65 | pub public_reactions: bool, 66 | #[sea_orm(column_name = "autoSensitive")] 67 | pub auto_sensitive: bool, 68 | #[sea_orm(column_name = "moderationNote")] 69 | pub moderation_note: String, 70 | #[sea_orm(column_type = "JsonBinary")] 71 | pub achievements: Json, 72 | #[sea_orm(column_name = "loggedInDates")] 73 | pub logged_in_dates: Vec, 74 | #[sea_orm(column_name = "preventAiLearning")] 75 | pub prevent_ai_learning: bool, 76 | #[sea_orm(column_name = "twoFactorBackupSecret")] 77 | pub two_factor_backup_secret: Option>, 78 | #[sea_orm(column_name = "verifiedLinks")] 79 | pub verified_links: Vec, 80 | #[sea_orm(column_name = "notificationRecieveConfig", column_type = "JsonBinary")] 81 | pub notification_recieve_config: Json, 82 | #[sea_orm(column_name = "hardMutedWords", column_type = "JsonBinary")] 83 | pub hard_muted_words: Json, 84 | #[sea_orm(column_name = "followingVisibility")] 85 | pub following_visibility: UserProfileFollowingvisibilityEnum, 86 | #[sea_orm(column_name = "followersVisibility")] 87 | pub followers_visibility: UserProfileFollowersVisibilityEnum, 88 | #[sea_orm(column_name = "followedMessage")] 89 | pub followed_message: Option, 90 | } 91 | 92 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 93 | pub enum Relation { 94 | #[sea_orm(has_many = "super::abuse_report_notification_recipient::Entity")] 95 | AbuseReportNotificationRecipient, 96 | #[sea_orm( 97 | belongs_to = "super::page::Entity", 98 | from = "Column::PinnedPageId", 99 | to = "super::page::Column::Id", 100 | on_update = "NoAction", 101 | on_delete = "SetNull" 102 | )] 103 | Page, 104 | #[sea_orm( 105 | belongs_to = "super::user::Entity", 106 | from = "Column::UserId", 107 | to = "super::user::Column::Id", 108 | on_update = "NoAction", 109 | on_delete = "Cascade" 110 | )] 111 | User, 112 | } 113 | 114 | impl Related for Entity { 115 | fn to() -> RelationDef { 116 | Relation::AbuseReportNotificationRecipient.def() 117 | } 118 | } 119 | 120 | impl Related for Entity { 121 | fn to() -> RelationDef { 122 | Relation::Page.def() 123 | } 124 | } 125 | 126 | impl Related for Entity { 127 | fn to() -> RelationDef { 128 | Relation::User.def() 129 | } 130 | } 131 | 132 | impl ActiveModelBehavior for ActiveModel {} 133 | -------------------------------------------------------------------------------- /src/entities/user_publickey.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_publickey")] 8 | pub struct Model { 9 | #[sea_orm(column_name = "userId", primary_key, auto_increment = false)] 10 | pub user_id: String, 11 | #[sea_orm(column_name = "keyId", unique)] 12 | pub key_id: String, 13 | #[sea_orm(column_name = "keyPem")] 14 | pub key_pem: String, 15 | } 16 | 17 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 18 | pub enum Relation { 19 | #[sea_orm( 20 | belongs_to = "super::user::Entity", 21 | from = "Column::UserId", 22 | to = "super::user::Column::Id", 23 | on_update = "NoAction", 24 | on_delete = "Cascade" 25 | )] 26 | User, 27 | } 28 | 29 | impl Related for Entity { 30 | fn to() -> RelationDef { 31 | Relation::User.def() 32 | } 33 | } 34 | 35 | impl ActiveModelBehavior for ActiveModel {} 36 | -------------------------------------------------------------------------------- /src/entities/user_security_key.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "user_security_key")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | #[sea_orm(column_name = "publicKey")] 14 | pub public_key: String, 15 | #[sea_orm(column_name = "lastUsed")] 16 | pub last_used: DateTimeWithTimeZone, 17 | pub name: String, 18 | pub counter: i64, 19 | #[sea_orm(column_name = "credentialDeviceType")] 20 | pub credential_device_type: Option, 21 | #[sea_orm(column_name = "credentialBackedUp")] 22 | pub credential_backed_up: Option, 23 | pub transports: Option>, 24 | } 25 | 26 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 27 | pub enum Relation { 28 | #[sea_orm( 29 | belongs_to = "super::user::Entity", 30 | from = "Column::UserId", 31 | to = "super::user::Column::Id", 32 | on_update = "NoAction", 33 | on_delete = "Cascade" 34 | )] 35 | User, 36 | } 37 | 38 | impl Related for Entity { 39 | fn to() -> RelationDef { 40 | Relation::User.def() 41 | } 42 | } 43 | 44 | impl ActiveModelBehavior for ActiveModel {} 45 | -------------------------------------------------------------------------------- /src/entities/webhook.rs: -------------------------------------------------------------------------------- 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.6 2 | 3 | use sea_orm::entity::prelude::*; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] 7 | #[sea_orm(table_name = "webhook")] 8 | pub struct Model { 9 | #[sea_orm(primary_key, auto_increment = false)] 10 | pub id: String, 11 | #[sea_orm(column_name = "userId")] 12 | pub user_id: String, 13 | pub name: String, 14 | pub on: Vec, 15 | pub url: String, 16 | pub secret: String, 17 | pub active: bool, 18 | #[sea_orm(column_name = "latestSentAt")] 19 | pub latest_sent_at: Option, 20 | #[sea_orm(column_name = "latestStatus")] 21 | pub latest_status: Option, 22 | } 23 | 24 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 25 | pub enum Relation { 26 | #[sea_orm( 27 | belongs_to = "super::user::Entity", 28 | from = "Column::UserId", 29 | to = "super::user::Column::Id", 30 | on_update = "NoAction", 31 | on_delete = "Cascade" 32 | )] 33 | User, 34 | } 35 | 36 | impl Related for Entity { 37 | fn to() -> RelationDef { 38 | Relation::User.def() 39 | } 40 | } 41 | 42 | impl ActiveModelBehavior for ActiveModel {} 43 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod cli; 2 | mod config; 3 | mod consts; 4 | mod db; 5 | mod entities; 6 | mod util; 7 | 8 | #[tokio::main] 9 | async fn main() -> Result<(), Box> { 10 | if let Err(e) = cli::command::exec().await { 11 | eprintln!("{}", e); 12 | } 13 | 14 | Ok(()) 15 | } 16 | -------------------------------------------------------------------------------- /src/util/id/aid.rs: -------------------------------------------------------------------------------- 1 | use std::num::ParseIntError; 2 | use std::sync::atomic::{AtomicU16, Ordering}; 3 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; 4 | 5 | use chrono::{DateTime, Local}; 6 | use lazy_static::lazy_static; 7 | use rand::Rng; 8 | use regex::Regex; 9 | 10 | use crate::util::radix::radix_encode; 11 | 12 | const TIME2000: u64 = 946684800000; 13 | static COUNTER: AtomicU16 = AtomicU16::new(0); 14 | 15 | lazy_static! { 16 | pub static ref AID_REGEX: Regex = Regex::new(r"^[0-9a-z](10)$").unwrap(); 17 | } 18 | 19 | #[allow(unused)] 20 | fn init_counter() -> u16 { 21 | let mut rng = rand::thread_rng(); 22 | rng.gen::() 23 | } 24 | 25 | fn get_time(time: u64) -> String { 26 | let timestamp = std::cmp::max(0, time - TIME2000); 27 | format!("{:0>8}", radix_encode(timestamp as i64, 36)) 28 | } 29 | 30 | fn get_noise() -> String { 31 | let counter_val = COUNTER.fetch_add(1, Ordering::SeqCst); 32 | format!("{:0>2}", radix_encode(counter_val as i64, 36)) 33 | } 34 | 35 | pub fn gen_aid(time: u64) -> Result { 36 | Ok(format!("{}{}", get_time(time), get_noise())) 37 | } 38 | 39 | pub fn parse(id: &str) -> Result { 40 | let time_part = &id[0..8]; 41 | let time = u64::from_str_radix(time_part, 36)? + TIME2000; 42 | Ok(UNIX_EPOCH + Duration::from_millis(time)) 43 | } 44 | 45 | pub fn formatted_time(id: &str) -> String { 46 | let systime = parse(id).unwrap(); 47 | let datetime: DateTime = systime.into(); 48 | datetime.to_rfc3339() 49 | } 50 | -------------------------------------------------------------------------------- /src/util/id/aidx.rs: -------------------------------------------------------------------------------- 1 | use std::num::ParseIntError; 2 | use std::sync::atomic::{AtomicU32, Ordering}; 3 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; 4 | 5 | use chrono::{DateTime, Local}; 6 | use lazy_static::lazy_static; 7 | use nanoid::nanoid; 8 | use regex::Regex; 9 | 10 | use crate::util::radix::radix_encode; 11 | 12 | const TIME2000: u64 = 946684800000; 13 | // const TIME_LENGTH: usize = 8; 14 | const NODE_LENGTH: usize = 4; 15 | const NOISE_LENGTH: usize = 4; 16 | 17 | static COUNTER: AtomicU32 = AtomicU32::new(0); 18 | lazy_static! { 19 | pub static ref AIDX_REGEX: Regex = Regex::new(r"^[0-9a-z]{16}$").unwrap(); 20 | pub static ref NODE_ID: String = nanoid!( 21 | NODE_LENGTH, 22 | &[ 23 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 24 | 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' 25 | ] 26 | ); 27 | } 28 | 29 | fn get_time(time: u64) -> String { 30 | let time = time as i64 - TIME2000 as i64; 31 | let timestamp = std::cmp::max(0, time); 32 | format!("{:0>8}", radix_encode(timestamp, 36)) 33 | } 34 | 35 | fn get_noise() -> String { 36 | let counter = COUNTER.fetch_add(1, Ordering::SeqCst); 37 | format!( 38 | "{:0>width$}", 39 | format!("{:x}", counter), 40 | width = NOISE_LENGTH 41 | ) 42 | } 43 | 44 | pub fn gen_aidx(time: u64) -> Result { 45 | Ok(format!("{}{}{}", get_time(time), &*NODE_ID, get_noise())) 46 | } 47 | 48 | pub fn parse(id: &str) -> Result { 49 | let time_part = &id[0..8]; 50 | let time = u64::from_str_radix(time_part, 36)? + TIME2000; 51 | Ok(UNIX_EPOCH + Duration::from_millis(time)) 52 | } 53 | 54 | pub fn formatted_time(id: &str) -> String { 55 | let systime = parse(id).unwrap(); 56 | let datetime: DateTime = systime.into(); 57 | datetime.to_rfc3339() 58 | } 59 | -------------------------------------------------------------------------------- /src/util/id/meid.rs: -------------------------------------------------------------------------------- 1 | use std::{num::ParseIntError, time::SystemTime}; 2 | 3 | use chrono::{DateTime, TimeZone, Utc}; 4 | use lazy_static::lazy_static; 5 | use rand::Rng; 6 | use regex::Regex; 7 | 8 | const CHARS: &str = "0123456789abcdef"; 9 | lazy_static! { 10 | static ref MEID_REGEX: Regex = Regex::new(r"^[0-9a-f](24)$").unwrap(); 11 | } 12 | 13 | fn get_time(mut time: u64) -> String { 14 | if time == 0 { 15 | return CHARS[0..1].to_string(); 16 | } 17 | 18 | time += 0x800000000000; 19 | 20 | format!("{:012x}", time) 21 | } 22 | 23 | fn get_random() -> String { 24 | let mut rng = rand::thread_rng(); 25 | (0..12) 26 | .map(|_| { 27 | let idx = rng.gen_range(0..CHARS.len()); 28 | CHARS.chars().nth(idx).unwrap() 29 | }) 30 | .collect() 31 | } 32 | 33 | // TODO: Resultにする 34 | pub fn gen_meid(time: u64) -> String { 35 | format!("{}{}", get_time(time), get_random()) 36 | } 37 | 38 | pub fn parse_meid(id: &str) -> Result { 39 | let timestamp = u64::from_str_radix(&id[0..12], 16).unwrap() - 0x800000000000; 40 | let time = SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(timestamp); 41 | Ok(time) 42 | } 43 | 44 | pub fn parse_meid_with_format(id: &str) -> DateTime { 45 | let time = parse_meid(id).unwrap(); 46 | let duration = time.duration_since(SystemTime::UNIX_EPOCH).unwrap(); 47 | Utc 48 | .timestamp_millis_opt(duration.as_millis() as i64) 49 | .unwrap() 50 | } 51 | 52 | // id: 81942b1629fec5c845bb697d 53 | // SystemTime: 1735889660414 54 | // date: 2025-01-03T07:34:20.414Z 55 | -------------------------------------------------------------------------------- /src/util/id/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod aid; 2 | pub mod aidx; 3 | pub mod meid; 4 | pub mod objectid; 5 | pub mod ulid; 6 | -------------------------------------------------------------------------------- /src/util/id/objectid.rs: -------------------------------------------------------------------------------- 1 | use std::{num::ParseIntError, time::SystemTime}; 2 | 3 | use chrono::{DateTime, TimeZone, Utc}; 4 | use lazy_static::lazy_static; 5 | use rand::Rng; 6 | use regex::Regex; 7 | 8 | const CHARS: &str = "0123456789abcdef"; 9 | lazy_static! { 10 | static ref OBJECT_ID_REGEX: Regex = Regex::new(r"^[0-9a-f]{24}$").unwrap(); 11 | } 12 | 13 | fn get_time(time: u64) -> String { 14 | format!("{:08x}", time) 15 | } 16 | 17 | fn get_random() -> String { 18 | let mut rng = rand::thread_rng(); 19 | (0..16) 20 | .map(|_| { 21 | let idx = rng.gen_range(0..CHARS.len()); 22 | CHARS.chars().nth(idx).unwrap() 23 | }) 24 | .collect() 25 | } 26 | 27 | // TODO: Resultにする 28 | pub fn gen_object_id(t: u64) -> String { 29 | format!("{}{}", get_time(t), get_random()) 30 | } 31 | 32 | pub fn parse_object_id(id: &str) -> Result { 33 | let timestamp = u64::from_str_radix(&id[0..8], 16).unwrap(); 34 | let time = SystemTime::UNIX_EPOCH + std::time::Duration::from_millis(timestamp * 1000); 35 | Ok(time) 36 | } 37 | 38 | pub fn parse_object_id_with_format(id: &str) -> DateTime { 39 | let time = parse_object_id(id).unwrap(); 40 | 41 | let duration = time.duration_since(SystemTime::UNIX_EPOCH).unwrap(); 42 | Utc 43 | .timestamp_millis_opt(duration.as_millis() as i64) 44 | .unwrap() 45 | } 46 | -------------------------------------------------------------------------------- /src/util/id/ulid.rs: -------------------------------------------------------------------------------- 1 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; 2 | use ulid::{DecodeError, Generator, Ulid}; 3 | 4 | use chrono::{DateTime, Local}; 5 | 6 | pub fn parse(id: &str) -> Result { 7 | let ulid = Ulid::from_string(id)?; 8 | let timestamp = ulid.timestamp_ms(); 9 | Ok(UNIX_EPOCH + Duration::from_millis(timestamp)) 10 | } 11 | 12 | pub fn formatted_time(id: &str) -> String { 13 | let systime = parse(id).unwrap(); 14 | let datetime: DateTime = systime.into(); 15 | datetime.to_rfc3339() 16 | } 17 | 18 | #[allow(clippy::let_and_return)] 19 | pub fn gen_ulid(time: u64) -> String { 20 | let mut gen = Generator::new(); 21 | // ここのSystemTime::now()を引数のi64から取得するようにする 22 | let now = SystemTime::UNIX_EPOCH + Duration::from_millis(time); 23 | let ulid = gen.generate_from_datetime(now).unwrap().to_string(); 24 | ulid 25 | } 26 | -------------------------------------------------------------------------------- /src/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod id; 2 | pub mod radix; 3 | pub mod vapid; 4 | -------------------------------------------------------------------------------- /src/util/radix.rs: -------------------------------------------------------------------------------- 1 | pub fn radix_encode(mut num: i64, radix: u32) -> String { 2 | if num == 0 { 3 | return "0".to_string(); 4 | } 5 | 6 | let mut result = String::new(); 7 | while num > 0 { 8 | let digit = (num % radix as i64) as u32; 9 | result.insert(0, std::char::from_digit(digit, radix).unwrap()); 10 | num /= radix as i64; 11 | } 12 | result 13 | } 14 | -------------------------------------------------------------------------------- /src/util/vapid.rs: -------------------------------------------------------------------------------- 1 | use base64::Engine; 2 | 3 | struct Key { 4 | key: openssl::ec::EcKey, 5 | } 6 | 7 | impl Key { 8 | fn name() -> openssl::nid::Nid { 9 | openssl::nid::Nid::X9_62_PRIME256V1 10 | } 11 | 12 | pub fn generate() -> VapidResult { 13 | let group = openssl::ec::EcGroup::from_curve_name(Key::name())?; 14 | let key = openssl::ec::EcKey::generate(&group)?; 15 | Ok(Key { key }) 16 | } 17 | 18 | pub fn to_private_raw(&self) -> String { 19 | let key = self.key.private_key(); 20 | let config = base64::engine::general_purpose::URL_SAFE_NO_PAD; 21 | config.encode(key.to_vec()) 22 | } 23 | 24 | pub fn to_public_raw(&self) -> String { 25 | let key = self.key.public_key(); 26 | let mut ctx = openssl::bn::BigNumContext::new().unwrap(); 27 | let group = openssl::ec::EcGroup::from_curve_name(Key::name()).unwrap(); 28 | 29 | let keybytes = key 30 | .to_bytes( 31 | &group, 32 | openssl::ec::PointConversionForm::UNCOMPRESSED, 33 | &mut ctx, 34 | ) 35 | .unwrap(); 36 | let config = base64::engine::general_purpose::URL_SAFE_NO_PAD; 37 | config.encode(&keybytes) 38 | } 39 | } 40 | 41 | pub type VapidResult = std::result::Result; 42 | 43 | #[derive(Debug)] 44 | pub struct VapidError { 45 | kind: VapidErrorKind, 46 | } 47 | 48 | #[derive(Debug, thiserror::Error)] 49 | pub enum VapidErrorKind { 50 | #[error("OpenSSL error: {:?}", .0)] 51 | OpenSSL(#[from] openssl::error::ErrorStack), 52 | #[error("JSON error: {:?}", .0)] 53 | Json(#[from] serde_json::Error), 54 | #[error("IO error: {:?}", .0)] 55 | File(#[from] std::io::Error), 56 | } 57 | 58 | impl std::fmt::Display for VapidError { 59 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 60 | self.kind.fmt(f) 61 | } 62 | } 63 | 64 | impl std::error::Error for VapidError { 65 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { 66 | self.kind.source() 67 | } 68 | } 69 | 70 | impl From for VapidError 71 | where 72 | VapidErrorKind: From, 73 | { 74 | fn from(err: T) -> Self { 75 | VapidError { 76 | kind: VapidErrorKind::from(err), 77 | } 78 | } 79 | } 80 | 81 | pub struct VapidKey { 82 | pub private_key: String, 83 | pub public_key: String, 84 | } 85 | 86 | pub fn generate() -> Result> { 87 | let keypair = Key::generate().map_err(|e| e.to_string())?; 88 | Ok(VapidKey { 89 | private_key: keypair.to_private_raw(), 90 | public_key: keypair.to_public_raw(), 91 | }) 92 | } 93 | 94 | #[cfg(test)] 95 | mod tests { 96 | use super::*; 97 | 98 | #[test] 99 | fn test_generate_vapid_key() { 100 | let key = generate().unwrap(); 101 | 102 | let private_key_bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD 103 | .decode(&key.private_key) 104 | .expect("Failed to decode private key"); 105 | assert_eq!(private_key_bytes.len(), 32); 106 | 107 | let public_key_bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD 108 | .decode(&key.public_key) 109 | .expect("Failed to decode public key"); 110 | assert_eq!(public_key_bytes.len(), 65); 111 | assert_eq!(public_key_bytes[0], 0x04); 112 | } 113 | } 114 | --------------------------------------------------------------------------------