├── .cargo └── config.toml ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── aardwolf-build.yml │ ├── aardwolf-test.yml │ ├── dependabot-combine.yml │ ├── docker.yml │ └── rust-clippy.yml ├── .gitignore ├── .vscode └── i18n-ally-custom-framework.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── ROADMAP.md ├── SECURITY.md ├── aardwolf-actix ├── Cargo.toml └── src │ ├── action.rs │ ├── error.rs │ ├── lib.rs │ ├── routes.rs │ ├── routes │ ├── app.rs │ ├── auth.rs │ ├── personas.rs │ └── posts.rs │ ├── session.rs │ ├── traits.rs │ ├── types.rs │ └── types │ ├── actor.rs │ ├── app.rs │ └── user.rs ├── aardwolf-api ├── Cargo.lock ├── Cargo.toml ├── README.md ├── aardwolf-api-common │ ├── Cargo.toml │ ├── config │ │ └── config.toml │ └── src │ │ ├── config.rs │ │ ├── lib.rs │ │ ├── models.rs │ │ └── models │ │ ├── direct_messages.rs │ │ ├── error.rs │ │ ├── posts.rs │ │ └── users.rs ├── backend-api │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── backend_engines │ │ ├── actix_backend.rs │ │ ├── actix_responses.rs │ │ └── warp_backend.rs │ │ ├── backend_main.rs │ │ ├── lib.rs │ │ ├── responses.rs │ │ └── routes │ │ └── posts.rs ├── database-api │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── connection_pool.rs │ │ ├── database_main.rs │ │ ├── lib.rs │ │ ├── mysql │ │ ├── mysql_main.rs │ │ └── schema.rs │ │ ├── postgres │ │ ├── postgres_main.rs │ │ └── schema.rs │ │ ├── sqlite │ │ ├── schema.rs │ │ └── sqlite_main.rs │ │ └── traits │ │ └── db_handler.rs ├── frontend-api │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── api_post_routes.rs │ │ ├── api_user_routes.rs │ │ ├── frontend_api.rs │ │ ├── handlers │ │ └── actix_handlers.rs │ │ ├── lib.rs │ │ └── routes │ │ └── actix_routes.rs ├── src │ └── main.rs └── tests │ └── models.rs ├── aardwolf-localization ├── Cargo.toml ├── Locales │ └── en-us.toml └── src │ ├── example_lib.rs.txt │ └── lib.rs ├── aardwolf-models ├── .gitignore ├── Cargo.toml ├── examples │ └── local_user_auth.rs ├── migrations │ ├── 00000000000000_diesel_initial_setup │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154357_add_files │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154415_add_images │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154543_add_users │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154603_add_base_actors │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154616_add_base_posts │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154635_add_followers │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154659_add_personas │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154746_add_links │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154755_add_posts │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154811_add_media_posts │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154838_add_comments │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-04-154903_add_reactions │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-05-235333_add_emails │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-05-235511_add_email_to_users │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-06-221443_add_local_auth │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-001818_add_timers │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-001826_add_events │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-002440_add_event_notifications │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-211402_add_roles │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-211409_add_user_roles │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-212221_add_permissions │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-07-212434_add_role_permissions │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-08-214834_add_follow_requests │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-14-012342_add_direct_posts │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-14-012357_add_groups │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-14-012407_add_group_base_actors │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-18-010722_add_delete_switch_persona_permissions │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004259_make_emails_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004310_make_shortnames_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004437_make_base_actor_urls_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004542_make_permissions_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004549_make_roles_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004642_make_file_path_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004702_make_follow_relation_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004711_make_group_relation_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004753_make_image_file_id_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004826_make_local_auth_user_id_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004903_make_post_base_post_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004943_make_role_permission_relations_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-004953_make_user_role_relations_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-005022_make_user_primary_email_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-005122_make_comments_post_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-04-20-010016_make_follow_requests_unique │ │ ├── down.sql │ │ └── up.sql │ ├── 2018-10-29-022958_remove_redundant_email_constraint │ │ ├── down.sql │ │ └── up.sql │ ├── 2019-01-12-200142_add_keys_to_base_actor │ │ ├── down.sql │ │ └── up.sql │ ├── 2019-01-12-200751_remove_json_stores │ │ ├── down.sql │ │ └── up.sql │ ├── 2019-01-12-214817_add_local_uuid │ │ ├── down.sql │ │ └── up.sql │ ├── 2019-01-13-035602_add-primary-persona │ │ ├── down.sql │ │ └── up.sql │ ├── 2019-01-18-211319_make_private_key_nullable │ │ ├── down.sql │ │ └── up.sql │ └── 2019-01-18-212737_add_activitypub_ids │ │ ├── down.sql │ │ └── up.sql └── src │ ├── base_actor.rs │ ├── base_actor │ ├── follow_request.rs │ ├── follower.rs │ ├── group.rs │ ├── group │ │ └── group_base_actor.rs │ └── persona.rs │ ├── base_post.rs │ ├── base_post │ ├── direct_post.rs │ ├── post.rs │ └── post │ │ ├── comment.rs │ │ ├── comment │ │ └── reaction.rs │ │ └── media_post.rs │ ├── file.rs │ ├── file │ └── image.rs │ ├── generate_urls.rs │ ├── lib.rs │ ├── link.rs │ ├── schema.rs │ ├── sql_types.rs │ ├── sql_types │ ├── follow_policy.rs │ ├── lang.rs │ ├── mime.rs │ ├── permission.rs │ ├── post_visibility.rs │ ├── reaction_type.rs │ ├── role.rs │ ├── timezone.rs │ └── url.rs │ ├── test_helper.rs │ ├── timer.rs │ ├── timer │ ├── event.rs │ └── event_notification.rs │ ├── user.rs │ └── user │ ├── email.rs │ ├── email │ └── token.rs │ ├── local_auth.rs │ ├── local_auth │ └── password.rs │ ├── permissions.rs │ ├── role.rs │ └── role │ ├── permission.rs │ ├── role_permission.rs │ └── user_role.rs ├── aardwolf-templates ├── Cargo.toml ├── build.rs ├── src │ ├── asides │ │ ├── mod.rs │ │ ├── settings.rs │ │ └── shortcuts.rs │ ├── containers │ │ ├── calendar.rs │ │ ├── mod.rs │ │ ├── preferences.rs │ │ ├── profile_edit.rs │ │ └── profile_view.rs │ ├── elements │ │ ├── alert.rs │ │ ├── input.rs │ │ ├── input_select.rs │ │ ├── input_text.rs │ │ ├── input_textarea.rs │ │ ├── lang_dropdown.rs │ │ ├── mod.rs │ │ ├── notification_content.rs │ │ ├── notification_dropdown.rs │ │ └── search_bar.rs │ ├── error │ │ ├── http_error.rs │ │ └── mod.rs │ ├── first_login.rs │ ├── home │ │ ├── feed.rs │ │ ├── home.rs │ │ ├── mod.rs │ │ └── nav_top.rs │ ├── lib.rs │ ├── posts │ │ ├── mod.rs │ │ ├── new_post.rs │ │ └── reply_post.rs │ ├── sign_in.rs │ └── sign_up.rs ├── templates │ ├── SAMPLE-LAYOUT.md │ ├── asides │ │ ├── settings.rs.html │ │ └── shortcuts.rs.html │ ├── base.rs.html │ ├── containers │ │ ├── calendar.rs.html │ │ ├── preferences.rs.html │ │ └── profile_edit.rs.html │ ├── elements │ │ ├── alert.rs.html │ │ ├── icon.rs.html │ │ ├── input.rs.html │ │ ├── input_checkbox.rs.html │ │ ├── input_email.rs.html │ │ ├── input_password.rs.html │ │ ├── input_password_confirm.rs.html │ │ ├── input_select.rs.html │ │ ├── input_text.rs.html │ │ ├── input_textarea.rs.html │ │ ├── lang_dropdown.rs.html │ │ ├── notification_content.rs.html │ │ ├── notification_dropdown.rs.html │ │ └── search_bar.rs.html │ ├── error │ │ └── error_http.html │ ├── first_login.rs.html │ ├── footer.rs.html │ ├── home │ │ ├── feed.rs.html │ │ ├── home.rs.html │ │ └── nav_top.rs.html │ ├── html_head.rs.html │ ├── posts │ │ ├── new_post.rs.html │ │ └── reply_post.rs.html │ ├── sign_in-v2-rs.html │ ├── sign_in.html │ ├── sign_in.rs.html │ ├── sign_up.html │ └── sign_up.rs.html └── translations │ ├── en │ └── LC_MESSAGES │ │ └── aardwolf.mo │ └── pl │ └── LC_MESSAGES │ └── aardwolf.mo ├── aardwolf-test-helpers ├── Cargo.toml └── src │ └── lib.rs ├── aardwolf-types ├── Cargo.toml └── src │ ├── apps.rs │ ├── csrf.rs │ ├── error.rs │ ├── forms.rs │ ├── forms │ ├── app.rs │ ├── auth │ │ ├── mod.rs │ │ ├── signin_form.rs │ │ └── signup_form.rs │ ├── personas │ │ ├── creation_fail.rs │ │ ├── creation_form.rs │ │ └── mod.rs │ └── posts.rs │ ├── lib.rs │ ├── operations.rs │ ├── operations │ ├── check_create_persona_permission.rs │ ├── check_create_post_permission.rs │ ├── check_delete_persona_permission.rs │ ├── confirm_account.rs │ ├── create_persona.rs │ ├── create_post.rs │ ├── delete_persona.rs │ ├── fetch_authenticated_user.rs │ ├── fetch_base_actor.rs │ ├── fetch_persona.rs │ ├── sign_in.rs │ └── sign_up.rs │ ├── scope.rs │ └── traits.rs ├── aardwolf-yew-frontend ├── Cargo.toml ├── index.html └── src │ ├── lib.rs │ ├── main.rs │ ├── templates.rs │ └── templates │ ├── elements.rs │ ├── elements │ ├── input_email.rs │ ├── input_password.rs │ ├── input_password_confirm.rs │ ├── input_username.rs │ └── main_title.rs │ ├── external.rs │ ├── layout.rs │ ├── layout │ └── footer.rs │ ├── pages.rs │ ├── pages │ └── sign_up.rs │ ├── shared.rs │ ├── shared │ ├── about_us.rs │ └── blank_html.rs │ ├── styles.rs │ └── styles │ ├── base.css │ └── scratchpad.css ├── build.rs ├── config ├── README.md ├── example.toml └── nginx │ ├── aardwolf-nginx.conf │ ├── basic_working.conf │ ├── includes │ ├── gzip.conf │ └── other-locations.conf │ └── snippets │ ├── self-signed.conf │ └── ssl-params.conf ├── db-init.sh ├── dev-setup ├── debian-setup.sh └── macos-setup.sh ├── diesel.toml ├── doc ├── AARDWOLF-SETUP.MD ├── DOCKER.md ├── README.md ├── SETUP-DATABASE.md ├── SETUP-NGINX.md ├── SETUP-NPM_WEBPACK-Deprecated.md ├── SETUP-POSTGRES-15_WIP.md ├── TEMPLATE_FILE_STRUCTURE.md ├── TROUBLESHOOTING.md ├── art-assets │ ├── README.md │ ├── aardwolf-final-1-no-circle.png │ ├── aardwolf-final-1-post-A-no-circle.png │ ├── aardwolf-final-1-post-A.png │ ├── aardwolf-final-1-post-no-circle.png │ ├── aardwolf-final-1-post.png │ ├── aardwolf-final-2-no-circle.png │ ├── aardwolf-final-2-post-A-no-circle.png │ ├── aardwolf-final-2-post-A.png │ ├── aardwolf-final-2-post-no-circle.png │ ├── aardwolf-final-2-post.png │ ├── aardwolf-final-2.png │ ├── aardwolf-logo.png │ ├── aardwolf-social-Gitlogo.png │ ├── aardwolf-social-banners-multi-size.svg │ ├── aardwolf-social-square_icon-dark.svg │ ├── aardwolf-social-square_icon-light.svg │ └── mascot-aardy_solo-300x300.svg ├── development-notes │ ├── 1.Email-Functionality.md │ ├── 2.Documentation-Review.md │ ├── 3.Interface-Languages.md │ ├── 4.ui_development.md │ ├── 5.Data-flow-diagrams.md │ ├── 6.API-Development.md │ ├── 7.Implement-Local-Timeline.md │ ├── 8. Implement-ActivityPub-and-Mastodon-compatible-functionality.md │ ├── dev-targets.md │ ├── notes-activitypub_rust.md │ ├── notes-app_architecture.md │ ├── notes-feature_set.md │ └── notes-user-instance-migration.md └── images │ ├── README.md │ ├── aardwolf-banner_solid-bg.png │ ├── aardwolf_banner.png │ ├── aardwolf_banner_small.png │ ├── homepage-demo.png │ ├── image.png │ └── social_passport.png ├── docker ├── Dockerfile ├── Dockerfile.actix ├── Dockerfile.postgresql ├── Dockerfile.yew ├── docker-compose.yml └── docker-entrypoint.sh ├── frontend-web-assets ├── README.md └── images │ └── aardwolf-logo.png ├── locales ├── TODO.yml └── app.yml ├── package-lock.json ├── po ├── LINGUAS ├── README.md ├── en.po └── pl.po ├── rust-toolchain.toml ├── src ├── bin │ ├── aardwolf-server.rs │ └── setup.rs └── lib.rs ├── tests ├── README.md └── resources │ ├── config-test.rs │ ├── config.toml │ └── mod-tests.rs └── translations /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | #- 2 | # Mold Linker for linux (replaces LLD) 3 | # New format 4 | [target.x86_64-unknown-linux-gnu] 5 | linker = "clang" 6 | rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"] 7 | 8 | # Syntax for older GCC 9 | #[target.x86_64-unknown-linux-gnu] 10 | #linker = "clang" 11 | #rustflags = ["-C", "link-arg=-fuse-ld=/path/to/mold"] 12 | #DefaultPath: /usr/local/bin/mold 13 | 14 | [env] 15 | OUT_DIR = "/compiled-templates" 16 | 17 | #- 18 | # Linkers for Windows, Linux (LLD), and MacOS 19 | # On Windows 20 | # ``` 21 | # cargo install -f cargo-binutils 22 | # rustup component add llvm-tools-preview 23 | # ``` 24 | # MS Visual C 25 | #[target.x86_64-pc-windows-msvc] 26 | #rustflags = ["-C", "link-arg=-fuse-ld=lld"] 27 | 28 | # GNU Compiler 29 | #[target.x86_64-pc-windows-gnu] 30 | #rustflags = ["-C", "link-arg=-fuse-ld=lld"] 31 | 32 | # On Linux: 33 | # - Ubuntu, `sudo apt-get install lld clang` 34 | # - Arch, `sudo pacman -S lld clang` 35 | #[target.x86_64-unknown-linux-gnu] 36 | #rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"] 37 | 38 | # On MacOS, `brew install michaeleisel/zld/zld` 39 | # Intel Silicon 40 | #[target.x86_64-apple-darwin] 41 | #rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"] 42 | 43 | # Apple Silicon 44 | #[target.aarch64-apple-darwin] 45 | #rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"] 46 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "cargo" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | 13 | # Disable version updates for cargo dependencies 14 | open-pull-requests-limit: 0 15 | 16 | - package-ecosystem: "npm" # See documentation for possible values 17 | directory: "/" # Location of package manifests 18 | schedule: 19 | interval: "weekly" 20 | 21 | # Disable version updates for npm dependencies 22 | open-pull-requests-limit: 0 23 | 24 | - package-ecosystem: "docker" # See documentation for possible values 25 | directory: "/" # Location of package manifests 26 | schedule: 27 | interval: "weekly" 28 | 29 | # Disable version updates for docker dependencies 30 | open-pull-requests-limit: 0 -------------------------------------------------------------------------------- /.github/workflows/aardwolf-test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI Test 3 | 4 | on: 5 | workflow_run: 6 | workflows: ["CI build"] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | cargo-test: 12 | name: Cargo Test 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Checkout the originating branch 16 | - uses: actions/checkout@v4 17 | with: 18 | ref: ${{ github.event.workflow_run.head_branch }} 19 | 20 | # Cache dependencies 21 | - name: Cache dependencies 22 | uses: actions/cache@v4 23 | with: 24 | path: ~/.cargo 25 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} 26 | restore-keys: | 27 | ${{ runner.os }}-cargo- 28 | 29 | # Run cargo test 30 | - name: Cargo test Aardwolf 31 | run: cargo test --all --verbose 32 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-combine.yml: -------------------------------------------------------------------------------- 1 | #- 2 | # CLI + GitHub action to combine dependabot PRs on GitHub repositories. 3 | # https://github.com/marketplace/actions/batch-dependabot-prs 4 | 5 | name: "Combine Dependabot PRs" 6 | on: 7 | workflow_dispatch: 8 | inputs: 9 | branches: 10 | description: 'Comma separate string of PRs to combine' 11 | required: false 12 | type: string 13 | 14 | jobs: 15 | combine-prs: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2.3.3 19 | # Gita To Do: test here if works 20 | with: 21 | persist-credentials: false 22 | - uses: gita-codaio/batch-dependabot@main 23 | with: 24 | branchPrefix: "dependabot" 25 | mustBeGreen: true 26 | combineBranchName: "combined-prs" 27 | ignoreLabel: "nocombine" 28 | baseBranch: "main" 29 | openPR: true 30 | allowSkipped: false 31 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | #- 2 | # GitHub Action for Docker Builds 3 | # Default script added 2023-06-02 4 | # 5 | name: 'Docker Image CI' 6 | 7 | on: 8 | pull_request: 9 | types: 10 | - opened 11 | - reopened 12 | branches: 13 | - main 14 | - 'banjofox/*' 15 | 16 | jobs: 17 | 18 | build: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v4 22 | - name: Build the Docker image 23 | run: docker build . --file docker/Dockerfile --tag my-image-name:$(date +%s) 24 | -------------------------------------------------------------------------------- /.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 | pull_request: 14 | branches: 15 | - main 16 | - 'banjofox/*' 17 | 18 | schedule: 19 | - cron: '41 3 * * 4' 20 | 21 | jobs: 22 | rust-clippy-analyze: 23 | name: Run rust-clippy analyzing 24 | runs-on: ubuntu-latest 25 | permissions: 26 | contents: read 27 | security-events: write 28 | actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status 29 | steps: 30 | - name: Checkout code 31 | uses: actions/checkout@v4 # Marketplace - https://github.com/marketplace/actions/checkout 32 | 33 | - name: Install rust toolchain 34 | uses: dtolnay/rust-toolchain@v1 # Marketplace - https://github.com/marketplace/actions/rustup-toolchain-install 35 | with: 36 | toolchain: stable 37 | components: rustfmt, clippy 38 | 39 | - name: Install required cargo 40 | run: cargo install clippy-sarif sarif-fmt 41 | 42 | - name: Add openssl 43 | run: cargo add openssl 44 | 45 | - name: Run rust-clippy 46 | run: 47 | cargo clippy 48 | --all-features 49 | --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt 50 | continue-on-error: true 51 | 52 | - name: Upload analysis results to GitHub 53 | uses: github/codeql-action/upload-sarif@v3 54 | with: 55 | sarif_file: rust-clippy-results.sarif 56 | wait-for-processing: true 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore .github. Includes dependabot, and workflow files 2 | # Don't forget to manually add stuff when updates are run!! 3 | .github/ 4 | 5 | # Ignore envrionment/OS files 6 | .DS_Store/ 7 | .vscode/ 8 | .idea/ 9 | .qodo/ 10 | 11 | # This is used for Docker 12 | .env 13 | 14 | # Generated by Cargo 15 | # will have compiled files and executables 16 | **/target/ 17 | **/dist/ 18 | 19 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 20 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 21 | #Cargo.lock 22 | 23 | # These are backup files generated by rustfmt 24 | **/*.rs.bk 25 | **/*.rs.swp 26 | 27 | # Ignore all SASS compilation files 28 | .sass-cache 29 | 30 | # Ignore Aardwolf-specific files 31 | aardwolf.toml 32 | aardwolf.log 33 | diesel.toml 34 | .config 35 | 36 | # Translations 37 | **/*.po~ 38 | translations/ 39 | po 40 | 41 | # Compiled templates 42 | src/templates.rs -------------------------------------------------------------------------------- /.vscode/i18n-ally-custom-framework.yml: -------------------------------------------------------------------------------- 1 | languageIds: 2 | - rust 3 | 4 | usageMatchRegex: 5 | - "[^\\w\\d]t!\\([\\s\\n\\r]*['\"]({key})['\"]" 6 | 7 | monopoly: true -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf" 3 | version = "0.1.0" 4 | authors = ["Banjo Fox ","Elijah Mark Anderson ", "Paul Woolcock ", "asonix ", "Nicholas Guyett "] 5 | description = "Powering connected social communities with free software." 6 | edition = "2021" 7 | 8 | [workspace] 9 | members = [ 10 | "aardwolf-actix", 11 | "aardwolf-localization", 12 | "aardwolf-models", 13 | "aardwolf-templates", 14 | "aardwolf-test-helpers", 15 | "aardwolf-types", 16 | "aardwolf-yew-frontend" 17 | ] 18 | 19 | [features] 20 | default = ["actix", "simple-logging"] 21 | actix = ["aardwolf-actix"] 22 | cargo-clippy = [] 23 | log-syslog = [] 24 | log-systemd = [] 25 | 26 | [dependencies] 27 | anyhow = "1.0.95" 28 | clap = "4.5.27" 29 | clap-verbosity-flag = "3.0.2" 30 | thiserror = "2.0.11" 31 | log = "0.4.25" 32 | # Use simple log files or stdout/stderr. Conflicts with use-systemd and log-* features. 33 | simple-logging = { version = "~2.0", optional = true } 34 | # Use syslog for writing logs. Conflicts with use-systemd and log-* features. 35 | #syslog = { version = "7.0.0", optional = true } 36 | # Integrate with Systemd, includes Journald for logging. Conflicts with log-* 37 | # features. 38 | #systemd = { version = "0.10.0", optional = true } 39 | 40 | # Locale crate - Putting it here fixes "cannot find function `_rust_i18n_translate` in the crate root" 41 | rust-i18n = "3.1.2" # https://crates.io/crates/rust-i18n 42 | 43 | [dependencies.aardwolf-actix] 44 | version = "0.1" 45 | path = "aardwolf-actix" 46 | optional = true 47 | 48 | [dependencies.config] 49 | version = "0.15.6" 50 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /aardwolf-actix/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-actix" 3 | version = "0.1.0" 4 | authors = ["asonix "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | actix = "0.13.5" 9 | actix-files = "0.6.6" 10 | actix-http = "3.9" 11 | actix-web = "4.9" 12 | config = "0.15.7" 13 | thiserror = "2.0.11" 14 | log = "0.4" 15 | r2d2 = "0.8" 16 | serde = "1.0" 17 | serde_derive = "1.0" 18 | serde_json = "1.0" 19 | uuid = "1.10" 20 | 21 | [dependencies.aardwolf-models] 22 | version = "0.1" 23 | path = "../aardwolf-models" 24 | 25 | [dependencies.aardwolf-templates] 26 | version = "0.1" 27 | path = "../aardwolf-templates" 28 | 29 | [dependencies.aardwolf-types] 30 | version = "0.1" 31 | path = "../aardwolf-types" 32 | 33 | [dependencies.actix-session] 34 | version = "0.10.1" 35 | features = ["cookie-session"] 36 | 37 | [dependencies.diesel] 38 | version = "2.2" 39 | default-features = false 40 | features = ["postgres", "uuid", "chrono"] 41 | 42 | [dependencies.futures] 43 | version = "0.3" 44 | features = ["compat"] 45 | -------------------------------------------------------------------------------- /aardwolf-actix/src/action.rs: -------------------------------------------------------------------------------- 1 | use actix_web::{http::header::LOCATION, HttpResponse}; 2 | 3 | pub fn redirect(to: &str) -> HttpResponse { 4 | HttpResponse::SeeOther() 5 | .append_header((LOCATION, to)) 6 | .finish() 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-actix/src/error.rs: -------------------------------------------------------------------------------- 1 | use actix_web::{http::header::LOCATION, HttpResponse, ResponseError}; 2 | use thiserror::Error; 3 | 4 | #[derive(Clone, Debug, Error)] 5 | #[error("Could not render template")] 6 | pub struct RenderError; 7 | 8 | impl ResponseError for RenderError { 9 | fn error_response(&self) -> HttpResponse { 10 | redirect_error("/", None) 11 | } 12 | } 13 | 14 | pub fn redirect_error(to: &str, msg: Option) -> HttpResponse { 15 | let msg = msg.map(|m| format!("?msg={}", m)).unwrap_or("".to_owned()); 16 | let location = format!("{}{}", to, msg); 17 | 18 | HttpResponse::SeeOther() 19 | .append_header((LOCATION, location.as_str())) 20 | .finish() 21 | } 22 | -------------------------------------------------------------------------------- /aardwolf-actix/src/routes.rs: -------------------------------------------------------------------------------- 1 | pub mod app; 2 | pub mod auth; 3 | pub mod personas; 4 | pub mod posts; 5 | -------------------------------------------------------------------------------- /aardwolf-actix/src/routes/app.rs: -------------------------------------------------------------------------------- 1 | use aardwolf_templates::home::Home; 2 | use aardwolf_types::forms::posts::PostCreationFormState; 3 | use actix_web::{web::Data, HttpResponse}; 4 | 5 | use crate::{ 6 | traits::RenderableExt, 7 | types::{actor::CurrentActor, user::SignedInUser}, 8 | }; 9 | 10 | pub(crate) async fn index( 11 | (_user, actor, i18n): (SignedInUser, CurrentActor, Data), 12 | ) -> HttpResponse { 13 | Home::new( 14 | &i18n.catalog, 15 | actor.1.shortname(), 16 | actor.0.profile_url().0.as_ref(), 17 | "csrf token", 18 | &PostCreationFormState { 19 | source: "".to_owned(), 20 | name: None, 21 | visibility: actor.1.default_visibility(), 22 | }, 23 | None, 24 | false, 25 | ) 26 | .ok() 27 | } 28 | -------------------------------------------------------------------------------- /aardwolf-actix/src/session.rs: -------------------------------------------------------------------------------- 1 | use actix_session::Session; 2 | 3 | pub fn from_session(session: &Session, key: &str, err: E) -> Result 4 | where 5 | I: serde::de::DeserializeOwned, 6 | { 7 | match session.get::(key) { 8 | Ok(maybe_item) => match maybe_item { 9 | Some(item) => Ok(item), 10 | None => Err(err), 11 | }, 12 | Err(_) => Err(err), 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aardwolf-actix/src/traits.rs: -------------------------------------------------------------------------------- 1 | use aardwolf_templates::Renderable; 2 | use actix_web::{http::header::CONTENT_TYPE, HttpResponse, HttpResponseBuilder}; 3 | 4 | pub trait RenderableExt: Renderable + Sized { 5 | fn ok(self) -> HttpResponse { 6 | HttpResponse::Ok().ructe(self) 7 | } 8 | 9 | fn created(self) -> HttpResponse { 10 | HttpResponse::Created().ructe(self) 11 | } 12 | 13 | fn not_found(self) -> HttpResponse { 14 | HttpResponse::NotFound().ructe(self) 15 | } 16 | } 17 | 18 | impl RenderableExt for T where T: Renderable {} 19 | 20 | pub trait WithRucte { 21 | fn ructe(&mut self, r: R) -> HttpResponse 22 | where 23 | R: Renderable; 24 | } 25 | 26 | impl WithRucte for HttpResponseBuilder { 27 | fn ructe(&mut self, r: R) -> HttpResponse 28 | where 29 | R: Renderable, 30 | { 31 | let mut buf = Vec::new(); 32 | 33 | match r.render(&mut buf) { 34 | Ok(_) => self.append_header((CONTENT_TYPE, "text/html")).body(buf), 35 | Err(e) => self 36 | .append_header((CONTENT_TYPE, "text/plain")) 37 | .body(format!("{}", e)), 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /aardwolf-actix/src/types.rs: -------------------------------------------------------------------------------- 1 | pub mod actor; 2 | pub mod app; 3 | pub mod user; 4 | -------------------------------------------------------------------------------- /aardwolf-actix/src/types/app.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /aardwolf-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-api" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [workspace] 7 | members = [ 8 | "aardwolf-api-common", 9 | "backend-api", 10 | "database-api", 11 | "frontend-api", 12 | ] 13 | 14 | [dependencies] 15 | aardwolf-api-common = { path = "aardwolf-api-common" } 16 | 17 | [profile.dev] 18 | panic = "unwind" 19 | 20 | [profile.release] 21 | panic = "unwind" -------------------------------------------------------------------------------- /aardwolf-api/README.md: -------------------------------------------------------------------------------- 1 | # Placeholder for API modules 2 | - Server: Actix, models, localization(?) 3 | - Frontend: Templates, and Yew Framework 4 | - Database: Modular database component (Postgres Default) -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-api-common" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [lib] 7 | name = "aardwolf_api_common" 8 | path = "src/lib.rs" 9 | 10 | [dependencies] 11 | config = "0.15.9" 12 | serde = { version = "1.0.218", features = ["derive"] } 13 | chrono = "0.4.40" -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/config/config.toml: -------------------------------------------------------------------------------- 1 | [backend] 2 | engine = "actix" 3 | use_trait_objects = true # Set to false for simpler struct-based approach 4 | 5 | [actix] 6 | host = "localhost" 7 | port = 8080 8 | 9 | [warp] 10 | host = "localhost" 11 | port = 8081 -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/config.rs: -------------------------------------------------------------------------------- 1 | use config::{Config, ConfigError, File}; 2 | use serde::Deserialize; 3 | 4 | #[derive(Debug, Deserialize)] 5 | pub struct BackendSettings { 6 | pub engine: String, 7 | pub use_trait_objects: Option, // Optional: Defaults to false if missing 8 | } 9 | 10 | #[derive(Debug, Deserialize)] 11 | pub struct ActixSettings { 12 | pub host: String, 13 | pub port: u16, 14 | } 15 | 16 | #[derive(Debug, Deserialize)] 17 | pub struct WarpSettings { 18 | pub host: String, 19 | pub port: u16, 20 | } 21 | 22 | #[derive(Debug, Deserialize)] 23 | pub struct DatabaseSettings { 24 | pub engine: String, 25 | } 26 | 27 | #[derive(Debug, Deserialize)] 28 | pub struct FrontendSettings { 29 | pub engine: String, 30 | } 31 | 32 | #[derive(Debug, Deserialize)] 33 | pub struct Settings { 34 | pub backend: BackendSettings, 35 | pub actix: Option, // Optional: Only used when Actix is selected 36 | pub warp: Option, // Optional: Only used when Warp is selected 37 | pub database: DatabaseSettings, 38 | pub frontend: FrontendSettings, 39 | } 40 | 41 | pub fn load_config() -> Result { 42 | let settings = Config::builder() 43 | .add_source(File::with_name("config.toml")) 44 | .set_default("backend.engine", "actix")? 45 | .set_default("backend.use_trait_objects", false)? // Default to struct-based 46 | .set_default("actix.host", "127.0.0.1")? 47 | .set_default("actix.port", 8080)? 48 | .set_default("warp.host", "127.0.0.1")? 49 | .set_default("warp.port", 8081)? 50 | .set_default("database.engine", "postgres")? 51 | .set_default("frontend.engine", "yew")? 52 | .build()?; 53 | 54 | settings.try_deserialize() 55 | } 56 | -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/lib.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api-common/src/lib.rs 2 | //! # Aardwolf API Common Files 3 | //! 4 | pub mod models; 5 | pub mod config; 6 | pub use models::posts::Post; 7 | pub use chrono::Utc; 8 | pub use serde::{Deserialize, Serialize}; -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/models.rs: -------------------------------------------------------------------------------- 1 | // Common API Models 2 | pub mod error; 3 | pub mod posts; 4 | pub mod users; 5 | pub mod direct_messages; 6 | 7 | pub use posts::Post; 8 | pub use serde::{Deserialize, Serialize}; 9 | pub use users::{User, UserData}; 10 | -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/models/direct_messages.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api-common/src/models/direct_messages.rs 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Serialize, Deserialize)] 5 | pub struct PrivateMessage { 6 | pub id: i32, 7 | pub sender_id: i32, 8 | pub recipient_id: i32, 9 | pub content: String, 10 | pub created_at: String, 11 | } 12 | 13 | #[derive(Serialize, Deserialize)] 14 | pub struct PrivateMessageReply(pub PrivateMessage); 15 | -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/models/error.rs: -------------------------------------------------------------------------------- 1 | // error.rs 2 | use serde::{Deserialize, Serialize}; 3 | 4 | pub trait Error { 5 | fn get_message(&self) -> String; 6 | fn get_code(&self) -> i32; 7 | } 8 | 9 | #[derive(Serialize, Deserialize)] 10 | pub struct ErrorImpl { 11 | pub message: String, 12 | pub code: i32, 13 | } 14 | 15 | impl Error for ErrorImpl { 16 | fn get_message(&self) -> String { 17 | self.message.clone() 18 | } 19 | 20 | fn get_code(&self) -> i32 { 21 | self.code 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/models/posts.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api-common/src/models/posts.rs 2 | use serde::{Deserialize, Serialize}; 3 | 4 | pub trait Post: Serialize + Send + Sync { 5 | fn get_id(&self) -> i32; 6 | fn get_title(&self) -> &str; 7 | fn get_content(&self) -> &str; 8 | fn get_created_at(&self) -> &str; 9 | fn get_updated_at(&self) -> &str; 10 | } 11 | 12 | #[derive(Serialize, Deserialize)] 13 | pub struct PostImpl { 14 | pub id: i32, 15 | pub title: String, 16 | pub content: String, 17 | pub created_at: String, 18 | pub updated_at: String, 19 | } 20 | 21 | impl Post for PostImpl { 22 | fn get_id(&self) -> i32 { 23 | self.id 24 | } 25 | 26 | fn get_title(&self) -> &str { 27 | &self.title 28 | } 29 | 30 | fn get_content(&self) -> &str { 31 | &self.content 32 | } 33 | 34 | fn get_created_at(&self) -> &str { 35 | &self.created_at 36 | } 37 | 38 | fn get_updated_at(&self) -> &str { 39 | &self.updated_at 40 | } 41 | } 42 | 43 | pub fn get_posts() -> Vec { 44 | vec![PostImpl { 45 | id: 1, 46 | title: "Example Post".to_string(), 47 | content: "Hello, world!".to_string(), 48 | created_at: "2025-03-07T12:00:00Z".to_string(), 49 | updated_at: "2025-03-07T12:30:00Z".to_string(), 50 | }] 51 | } 52 | -------------------------------------------------------------------------------- /aardwolf-api/aardwolf-api-common/src/models/users.rs: -------------------------------------------------------------------------------- 1 | // users.rs 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Serialize, Deserialize)] 5 | pub struct User { 6 | pub id: i32, 7 | pub name: String, 8 | pub email: String, 9 | } 10 | 11 | pub struct UserData { 12 | pub id: i32, 13 | pub name: String, 14 | pub email: String, 15 | } 16 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-api-backend" 3 | version = "0.1.0" 4 | edition = "2024" 5 | authors = ["BanjoFox "] 6 | description = "Backend API for Aardwolf" 7 | license = "AGPL-3" 8 | documentation = "https://docs.rs/aardwolf-api-backend" 9 | repository = "https://github.com/SlantyDog/aardwolf-api" 10 | 11 | [dependencies] 12 | # Internal Dependencies 13 | aardwolf-api-common = { path = "../aardwolf-api-common" } 14 | 15 | # External Dependencies 16 | actix-web = { version = "4.10.2", features = ["openssl", "rustls"], optional = true } 17 | warp = { version = "0.3", optional = true } 18 | tokio = { version = "1.44.2", features = ["rt", "rt-multi-thread", "macros"] } 19 | serde = { version = "1.0.219", features = ["derive"] } 20 | chrono = "0.4.40" 21 | 22 | [features] 23 | default = ["actix-web"] 24 | warp-backend = ["warp"] 25 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/README.md: -------------------------------------------------------------------------------- 1 | # Placeholder for server/backend API code 2 | 3 | Some endpoint suggestions: 4 | ``` 5 | POST /api/auth/login: Authenticate a user and generate a token for accessing protected routes. 6 | POST /api/users: Create a new user account. 7 | GET /api/users/:userId: Retrieve user details by user ID. 8 | PUT /api/users/:userId: Update user information. 9 | ``` -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/backend_engines/actix_backend.rs: -------------------------------------------------------------------------------- 1 | // backend-api/src/backend_engines/actix_backend.rs 2 | use crate::backend_engines::actix_responses::ActixPrivateMessageReply; 3 | use crate::routes::posts::{create_post, get_posts}; 4 | use aardwolf_api_common::models::direct_messages::{PrivateMessage, PrivateMessageReply}; 5 | use aardwolf_api_common::models::posts::PostImpl; 6 | use actix_web::{web, HttpResponse, Scope, Responder}; 7 | 8 | /// Creates a new post and returns the created post as JSON. 9 | async fn create_post_actix(data: web::Json) -> HttpResponse { 10 | match create_post(data.into_inner()).await { 11 | Ok(post) => HttpResponse::Created().json(post), 12 | Err(err) => HttpResponse::InternalServerError().body(err), 13 | } 14 | } 15 | 16 | /// Retrieves all posts as JSON. 17 | async fn get_posts_actix() -> HttpResponse { 18 | match get_posts().await { 19 | Ok(posts) => HttpResponse::Ok().json(posts), 20 | Err(err) => HttpResponse::InternalServerError().body(err), 21 | } 22 | } 23 | 24 | /// Sends a new private message. 25 | async fn send_private_message(data: web::Json) -> impl Responder { 26 | ActixPrivateMessageReply(PrivateMessageReply(data.into_inner())) 27 | } 28 | 29 | /// Retrieves a private message reply. 30 | async fn get_private_message_reply(data: web::Json) -> impl Responder { 31 | ActixPrivateMessageReply(PrivateMessageReply(data.into_inner())) 32 | } 33 | 34 | /// Configures Actix routes. 35 | pub fn configure_routes() -> Scope { 36 | web::scope("/api") 37 | .route("/posts", web::get().to(get_posts_actix)) 38 | .route("/posts", web::post().to(create_post_actix)) 39 | .route("/messages", web::post().to(send_private_message)) 40 | .route("/messages/reply", web::post().to(get_private_message_reply)) 41 | } 42 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/backend_engines/actix_responses.rs: -------------------------------------------------------------------------------- 1 | // backend-api/src/backend_engines/actix_responses.rs 2 | use aardwolf_api_common::models::direct_messages::PrivateMessageReply as CommonPrivateMessageReply; 3 | use actix_web::{Responder, HttpResponse, HttpRequest}; 4 | use actix_web::body::BoxBody; 5 | 6 | pub struct ActixPrivateMessageReply(pub CommonPrivateMessageReply); 7 | 8 | impl Responder for ActixPrivateMessageReply { 9 | type Body = BoxBody; 10 | 11 | fn respond_to(self, _req: &HttpRequest) -> HttpResponse { 12 | HttpResponse::Ok().json(&self.0 .0) // unpack twice! 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/backend_engines/warp_backend.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api/backend-engines/warp_backend.rs 2 | use crate::responses::ErrorResponse; 3 | use warp::reject::Reject; 4 | 5 | impl Reject for ErrorResponse {} 6 | 7 | async fn create_post_warp() { 8 | todo!() 9 | } 10 | 11 | async fn get_posts_warp() { 12 | todo!() 13 | } 14 | 15 | pub fn routes() { 16 | todo!() 17 | } 18 | 19 | #[tokio::main] 20 | async fn main() { 21 | todo!() 22 | } 23 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/backend_main.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api/backend-api/src/backend_main.rs 2 | use aardwolf_api_common::config::load_config; 3 | 4 | fn main() { 5 | let settings = load_config().expect("Failed to load config"); 6 | 7 | println!("Backend engine: {}", settings.backend.engine); 8 | 9 | match settings.backend.engine.as_str() { 10 | "actix" => { 11 | if let Some(actix) = settings.actix { 12 | println!("Starting Actix on {}:{}", actix.host, actix.port); 13 | } 14 | } 15 | "warp" => { 16 | if let Some(warp) = settings.warp { 17 | println!("Starting Warp on {}:{}", warp.host, warp.port); 18 | } 19 | } 20 | _ => { 21 | println!("Unknown backend selected!"); 22 | } 23 | } 24 | 25 | println!("Database engine: {}", settings.database.engine); 26 | println!("Frontend engine: {}", settings.frontend.engine); 27 | } 28 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | // backend-api/src/lib.rs 2 | pub mod backend_engines { 3 | pub mod actix_backend; 4 | pub mod actix_responses; 5 | pub mod warp_backend; 6 | } 7 | pub mod routes { 8 | pub mod posts; 9 | } 10 | pub use routes::posts; // Allows calling `crate::posts` directly 11 | pub mod responses; 12 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/responses.rs: -------------------------------------------------------------------------------- 1 | // responses.rs 2 | pub trait Response { 3 | fn into_response(self) -> Self; 4 | } 5 | 6 | #[derive(Debug)] 7 | pub(crate) struct ErrorResponse { 8 | pub(crate) message: String, 9 | } 10 | 11 | impl std::error::Error for ErrorResponse {} 12 | 13 | impl std::fmt::Display for ErrorResponse { 14 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 15 | write!(f, "{}", self.message) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aardwolf-api/backend-api/src/routes/posts.rs: -------------------------------------------------------------------------------- 1 | // backend-api/src/routes/posts.rs 2 | use aardwolf_api_common::models::posts::PostImpl; 3 | use aardwolf_api_common::Utc; 4 | 5 | /// Creates a new post. 6 | pub async fn create_post(post: PostImpl) -> Result { 7 | Ok(PostImpl { 8 | id: 1, 9 | title: post.title, 10 | content: post.content, 11 | created_at: Utc::now().to_rfc3339(), 12 | updated_at: Utc::now().to_rfc3339(), 13 | }) 14 | } 15 | 16 | /// Retrieves all posts. 17 | pub async fn get_posts() -> Result, String> { 18 | Ok(vec![PostImpl { 19 | id: 1, 20 | title: "Post 1".to_string(), 21 | content: "This is post 1".to_string(), 22 | created_at: Utc::now().to_rfc3339(), 23 | updated_at: Utc::now().to_rfc3339(), 24 | }]) 25 | } 26 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-database-api" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [lib] 7 | name = "database_api" 8 | path = "src/lib.rs" 9 | 10 | [dependencies] 11 | # Internal Dependencies 12 | aardwolf-api-common = { path = "../aardwolf-api-common" } 13 | 14 | # External Dependencies 15 | diesel = { version = "2.2.8", features = ["postgres", "r2d2"] } 16 | diesel-derive-enum = "2.1.0" 17 | serde = { version = "1.0.218", features = ["derive"] } 18 | 19 | [features] 20 | default = ["postgres"] 21 | postgres = ["diesel/postgres"] 22 | mysql = ["diesel/mysql"] 23 | sqlite = ["diesel/sqlite"] 24 | 25 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/README.md: -------------------------------------------------------------------------------- 1 | # Placeholder for database API code 2 | 3 | Some endpoint suggestions: 4 | 5 | ``` 6 | GET /api/db/users: Retrieve all users from the database. 7 | POST /api/db/users: Add a new user to the database. 8 | GET /api/db/users/:userId/posts: Retrieve posts by a specific user. 9 | GET /api/db/posts: Retrieve all posts from the database. 10 | POST /api/db/posts: Add a new post to the database. 11 | PUT /api/db/posts/:postId: Update a post in the database. 12 | DELETE /api/db/posts/:postId: Delete a post from the database. 13 | POST /api/db/posts/:postId/like: Add a like to a post. 14 | POST /api/db/posts/:postId/comment: Add a comment to a post. 15 | GET /api/db/posts/:postId/comments: Retrieve comments for a post. 16 | ``` -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/connection_pool.rs: -------------------------------------------------------------------------------- 1 | // connection_pool.rs 2 | pub struct DatabaseConnectionPool { 3 | pool: Pool>, 4 | } 5 | 6 | impl DatabaseConnectionPool { 7 | pub fn builder() -> ConnectionPoolBuilder { 8 | ConnectionPoolBuilder::new() 9 | } 10 | } 11 | 12 | pub struct ConnectionPoolBuilder { 13 | url: String, 14 | } 15 | 16 | impl ConnectionPoolBuilder { 17 | pub fn new() -> Self { 18 | ConnectionPoolBuilder { url: String::new() } 19 | } 20 | 21 | pub fn url(mut self, url: String) -> Self { 22 | self.url = url; 23 | self 24 | } 25 | 26 | pub fn build(self) -> DatabaseConnectionPool { 27 | let manager = ConnectionManager::::new(self.url); 28 | let pool = Pool::new(manager).unwrap(); 29 | DatabaseConnectionPool { pool } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/database_main.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api/database-api/src/database_main.rs 2 | // 3 | use crate::database_main::DatabaseConnection::MysqlConnection; 4 | use crate::postgres::PgConnection; 5 | use crate::sqlite::SqliteConnection; 6 | 7 | pub enum DatabaseConnection { 8 | PgConnection(PgConnection), 9 | MysqlConnection(MysqlConnection), 10 | SqliteConnection(SqliteConnection), 11 | } 12 | 13 | pub trait MyConnection { 14 | fn execute_query( 15 | &self, 16 | query: Box + 'static>, 17 | ) -> Result<(), diesel::result::Error>; 18 | fn execute_transaction( 19 | &self, 20 | transaction: Box + 'static>, 21 | ) -> Result<(), diesel::result::Error>; 22 | } 23 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | // database-api/src/lib.rs 2 | pub mod connection_pool; 3 | pub mod database_main; 4 | pub mod traits{ 5 | pub mod db_handler; 6 | } 7 | pub mod mysql{ 8 | pub mod mysql_main; 9 | } 10 | pub mod postgres{ 11 | pub mod postgres_main; 12 | } 13 | pub mod sqlite{ 14 | pub mod sqlite_main; 15 | } 16 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/mysql/schema.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/postgres/schema.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/sqlite/schema.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/sqlite/sqlite_main.rs: -------------------------------------------------------------------------------- 1 | use crate::database::MyConnection; 2 | use crate::Error; 3 | // sqlite.rs 4 | use crate::Post; 5 | pub(crate) use diesel::sqlite::SqliteConnection; 6 | 7 | pub struct SqliteHandler { 8 | connection: rusqlite::Connection, 9 | database_path: String, 10 | is_active: bool, 11 | schema: Vec, 12 | } 13 | 14 | impl MyConnection for SqliteConnection { 15 | fn execute_query(&self, query: &str) -> Result<(), diesel::result::Error> { 16 | // implementation for SQLite 17 | } 18 | 19 | fn execute_transaction(&self, transaction: &str) -> Result<(), diesel::result::Error> { 20 | // implementation for SQLite 21 | } 22 | } 23 | 24 | impl DbHandler for SqliteHandler { 25 | fn get_posts(&self) -> Vec { 26 | // implement sqlite-specific logic to retrieve posts 27 | todo!() 28 | } 29 | 30 | fn create_post(&self, post: Post) -> Result<(), Error> { 31 | // implement sqlite-specific logic to create a post 32 | todo!() 33 | } 34 | 35 | fn update_post(&self, post_id: i32, post: Post) -> Result<(), Error> { 36 | // implement sqlite-specific logic to update a post 37 | todo!() 38 | } 39 | 40 | fn delete_post(&self, post_id: i32) -> Result<(), Error> { 41 | // implement sqlite-specific logic to delete a post 42 | todo!() 43 | } 44 | 45 | fn like_post(&self, post_id: i32) -> Result<(), Error> { 46 | // implement sqlite-specific logic to like a post 47 | todo!() 48 | } 49 | 50 | fn comment_post(&self, post_id: i32, comment: Comment) -> Result<(), Error> { 51 | // implement sqlite-specific logic to comment on a post 52 | todo!() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /aardwolf-api/database-api/src/traits/db_handler.rs: -------------------------------------------------------------------------------- 1 | // database-api/src/traits/db_handler.rs 2 | extern crate aardwolf_api_common; 3 | use aardwolf_api_common::models::error::Error; 4 | use aardwolf_api_common::models::posts::Post; 5 | 6 | pub trait DbHandler { 7 | fn get_posts(&self) -> Result>, Box>; 8 | fn create_post(&self, post: Box) -> Result<(), Box>; 9 | fn update_post(&self, post_id: i32, post: Box) -> Result<(), Box>; 10 | fn delete_post(&self, post_id: i32) -> Result<(), Box>; 11 | fn like_post(&self, post_id: i32) -> Result<(), Box>; 12 | } 13 | -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "aardwolf-api-frontend" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-api-frontend" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | # Internal Dependencies 8 | aardwolf-api-common = { path = "../aardwolf-api-common" } 9 | actix-web = "4.10.2" 10 | 11 | # External Dependencies -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/README.md: -------------------------------------------------------------------------------- 1 | # Placeholder for frontend API code 2 | 3 | Some endpoint suggestions: 4 | ``` 5 | GET /api/posts: Retrieve a list of posts to display on the feed. 6 | POST /api/posts/create: Create a new post. 7 | PUT /api/posts/update/:postId: Update a post. 8 | DELETE /api/posts/delete/:postId: Delete a post. 9 | POST /api/posts/like/:postId: Like a post. 10 | POST /api/posts/comment/:postId: Add a comment to a post. 11 | GET /api/users/:userId/posts: Retrieve posts by a specific user. 12 | GET /api/users/:userId/followers: Retrieve followers of a user. 13 | POST /api/users/follow/:userId: Follow a user. 14 | POST /api/users/unfollow/:userId: Unfollow a user. 15 | ``` -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/src/api_user_routes.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api/frontend-api/src/api_user_routes.rs 2 | 3 | pub trait ApiUserRoutes { 4 | fn get_users_route(&self) -> Box; 5 | fn get_user_posts_route(&self) -> Box; 6 | fn get_user_followers_route(&self) -> Box; 7 | fn follow_user_route(&self) -> Box; 8 | fn unfollow_user_route(&self) -> Box; 9 | } 10 | 11 | pub trait RouteHandler { 12 | fn handle(&self, request: &Request) -> Response; 13 | } 14 | 15 | // Define a struct to hold the routes 16 | pub struct ApiUserRoutesImpl { 17 | pub get_users: Box, 18 | pub get_user_posts: Box, 19 | pub get_user_followers: Box, 20 | pub follow_user: Box, 21 | pub unfollow_user: Box, 22 | } 23 | 24 | impl ApiUserRoutes for ApiUserRoutesImpl { 25 | fn get_users_route(&self) -> Box { 26 | self.get_users.clone() 27 | } 28 | 29 | fn get_user_posts_route(&self) -> Box { 30 | self.get_user_posts.clone() 31 | } 32 | 33 | fn get_user_followers_route(&self) -> Box { 34 | self.get_user_followers.clone() 35 | } 36 | 37 | fn follow_user_route(&self) -> Box { 38 | self.follow_user.clone() 39 | } 40 | 41 | fn unfollow_user_route(&self) -> Box { 42 | self.unfollow_user.clone() 43 | } 44 | } 45 | 46 | // Define the main function to create the HTTP server 47 | #[actix_web::main] 48 | async fn main() -> std::io::Result<()> { 49 | let routes = ApiUserRoutesImpl { 50 | get_users: Box::new(handlers::GetUsersHandler), 51 | get_user_posts: Box::new(handlers::GetUserPostsHandler), 52 | get_user_followers: Box -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/src/frontend_api.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aardwolf-Social/aardwolf-social/c6e7cf8c8b9d2a95b47fffe9729777bad6902d86/aardwolf-api/frontend-api/src/frontend_api.rs -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/src/handlers/actix_handlers.rs: -------------------------------------------------------------------------------- 1 | // frontend-api/src/handlers/handlers.rs 2 | mod handlers { 3 | use actix_web::{HttpResponse, Responder}; 4 | 5 | pub async fn get_user_posts() -> impl Responder { 6 | // Logic to retrieve a list of user posts (replace this with actual implementation) 7 | let posts = vec!["Post 1", "Post 2", "Post 3"]; // Sample posts 8 | 9 | HttpResponse::Ok().json(posts) 10 | } 11 | 12 | pub async fn get_user_followers() -> impl Responder { 13 | // Logic to retrieve followers of a user (replace this with actual implementation) 14 | let followers = vec!["Follower 1", "Follower 2", "Follower 3"]; // Sample followers 15 | 16 | HttpResponse::Ok().json(followers) 17 | } 18 | 19 | pub async fn follow_user() -> impl Responder { 20 | // Logic to follow a user (replace this with actual implementation) 21 | let message = "User followed successfully"; // Sample message 22 | 23 | HttpResponse::Ok().json(message) 24 | } 25 | 26 | pub async fn unfollow_user() -> impl Responder { 27 | // Logic to unfollow a user (replace this with actual implementation) 28 | let message = "User unfollowed successfully"; // Sample message 29 | 30 | HttpResponse::Ok().json(message) 31 | } 32 | } -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/src/lib.rs: -------------------------------------------------------------------------------- 1 | // frontend-api/src/lib.rs 2 | mod api_post_routes; 3 | mod api_user_routes; 4 | 5 | pub mod routes { 6 | pub mod actix_routes; 7 | } 8 | 9 | pub mod handlers { 10 | pub mod actix_handlers; 11 | } -------------------------------------------------------------------------------- /aardwolf-api/frontend-api/src/routes/actix_routes.rs: -------------------------------------------------------------------------------- 1 | // frontend-api/src/routes/routes.rs 2 | pub mod routes { 3 | pub fn get_routes() -> Vec { 4 | vec![ 5 | actix_web::Route::new("/api/users/:userId/posts") 6 | .method(actix_web::http::Method::GET) 7 | .to("get_user_posts"), 8 | actix_web::Route::new("/api/users/:userId/followers") 9 | .method(actix_web::http::Method::GET) 10 | .to("get_user_followers"), 11 | actix_web::Route::new("/api/users/follow/:userId") 12 | .method(actix_web::http::Method::GET) 13 | .to("follow_user"), 14 | actix_web::Route::new("/api/users/unfollow/:userId") 15 | .method(actix_web::http::Method::GET) 16 | .to("unfollow_user"), 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aardwolf-api/src/main.rs: -------------------------------------------------------------------------------- 1 | // aardwolf-api/src/main.rs 2 | 3 | extern crate aardwolf_api_common as common; 4 | 5 | fn main() { 6 | // Test the models module 7 | let post_data = common::models::posts::PostData { 8 | title: "Test Post".to_string(), 9 | content: "This is a test post".to_string(), 10 | }; 11 | println!("Post Data: {:?}", post_data); 12 | 13 | let post = common::Post { 14 | id: 1, 15 | title: "Test Post".to_string(), 16 | content: "This is a test post".to_string(), 17 | }; 18 | println!("Post: {:?}", post); 19 | 20 | // Test other modules here... 21 | } -------------------------------------------------------------------------------- /aardwolf-api/tests/models.rs: -------------------------------------------------------------------------------- 1 | // tests/models.rs 2 | #[cfg(test)] 3 | mod tests { 4 | use aardwolf_api_common::models::posts; 5 | #[test] 6 | fn test_post_data() { 7 | // Test the PostData struct here... 8 | } 9 | 10 | #[test] 11 | fn test_post() { 12 | // Test the Post struct here... 13 | } 14 | } -------------------------------------------------------------------------------- /aardwolf-localization/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "aardwolf-localization" 4 | version = "0.1.0" 5 | edition = "2021" 6 | [dependencies] 7 | rust-i18n = "3.1.2" 8 | -------------------------------------------------------------------------------- /aardwolf-localization/src/example_lib.rs.txt: -------------------------------------------------------------------------------- 1 | // Load I18n macro, for allow you use `t!` macro in anywhere. 2 | #[macro_use] 3 | extern crate rust_i18n; 4 | 5 | // Init translations for current crate. 6 | // This will load Configuration using the `[package.metadata.i18n]` section in `Cargo.toml` if exists. 7 | // Or you can pass arguments by `i18n!` to override it. 8 | i18n!("locales"); 9 | 10 | // Config fallback missing translations to "en" locale. 11 | // Use `fallback` option to set fallback locale. 12 | // 13 | i18n!("locales", fallback = "en"); 14 | 15 | // Or more than one fallback with priority. 16 | // 17 | i18n!("locales", fallback = ["en", "es"]); 18 | 19 | // Use a short hashed key as an identifier for long string literals 20 | // to optimize memory usage and lookup speed. 21 | // The key generation algorithm is `${Prefix}${Base62(SipHash13("msg"))}`. 22 | i18n!("locales", minify_key = true); 23 | // 24 | // Alternatively, you can customize the key length, prefix, 25 | // and threshold for the short hashed key. 26 | i18n!("locales", 27 | minify_key = true, 28 | minify_key_len = 12, 29 | minify_key_prefix = "t_", 30 | minify_key_thresh = 64 31 | ); 32 | // Now, if the message length exceeds 64, the `t!` macro will automatically generate 33 | // a 12-byte short hashed key with a "t_" prefix for it, if not, it will use the original. 34 | 35 | // If no any argument, use config from Cargo.toml or default. 36 | i18n!(); -------------------------------------------------------------------------------- /aardwolf-localization/src/lib.rs: -------------------------------------------------------------------------------- 1 | //- 2 | // Banjo's notes: 3 | // For the FULL list of options please refer to: 4 | // ./aardwolf-localization/example_lib.rs 5 | 6 | // 7 | // Start of rust-i18n configuration 8 | // Load I18n macro, for allow you use `t!` macro in anywhere. 9 | 10 | #[macro_use] 11 | extern crate rust_i18n; 12 | 13 | i18n!("locales", fallback = "en"); // This must be at the crate root 14 | -------------------------------------------------------------------------------- /aardwolf-models/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /aardwolf-models/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-models" 3 | version = "0.1.0" 4 | authors = ["asonix "] 5 | description = "Database interaction for the Aardwolf project" 6 | edition = "2021" 7 | 8 | [dependencies] 9 | anyhow = "1.0" 10 | bcrypt = "0.17.0" 11 | chrono = "0.4.38" 12 | chrono-tz = "0.10.1" 13 | log = "0.4" 14 | mime = "0.3" 15 | openssl = "0.10" 16 | serde = "1.0" 17 | serde_json = "1.0" 18 | strum = "0.26.3" 19 | strum_macros = "0.26.4" 20 | thiserror = "2.0.11" 21 | url = "2.5" 22 | dotenvy ="0.15" 23 | env_logger = "^0.11.5" 24 | rand = "0.9.0" 25 | 26 | [dependencies.uuid] 27 | version = "1.10" 28 | features = ["v4"] 29 | 30 | [features] 31 | default = [] 32 | test = [] 33 | 34 | [dependencies.diesel] 35 | version = "2.2" 36 | features = ["chrono", "postgres", "serde_json", "uuid"] 37 | 38 | [dev-dependencies] 39 | env_logger = "^0.11.5" 40 | serde_derive = "1.0" 41 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/00000000000000_diesel_initial_setup/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); 2 | DROP FUNCTION IF EXISTS diesel_set_updated_at(); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/00000000000000_diesel_initial_setup/up.sql: -------------------------------------------------------------------------------- 1 | -- This file was automatically created by Diesel to setup helper functions 2 | -- and other internal bookkeeping. This file is safe to edit, any future 3 | -- changes will be added to existing projects as new migrations. 4 | 5 | 6 | 7 | 8 | -- Sets up a trigger for the given table to automatically set a column called 9 | -- `updated_at` whenever the row is modified (unless `updated_at` was included 10 | -- in the modified columns) 11 | -- 12 | -- # Example 13 | -- 14 | -- ```sql 15 | -- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); 16 | -- 17 | -- SELECT diesel_manage_updated_at('users'); 18 | -- ``` 19 | CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$ 20 | BEGIN 21 | EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s 22 | FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); 23 | END; 24 | $$ LANGUAGE plpgsql; 25 | 26 | CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$ 27 | BEGIN 28 | IF ( 29 | NEW IS DISTINCT FROM OLD AND 30 | NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at 31 | ) THEN 32 | NEW.updated_at := current_timestamp; 33 | END IF; 34 | RETURN NEW; 35 | END; 36 | $$ LANGUAGE plpgsql; 37 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154357_add_files/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE files; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154357_add_files/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE files ( 3 | id SERIAL PRIMARY KEY, 4 | file_path VARCHAR NOT NULL, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 7 | ); 8 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154415_add_images/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE images; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154415_add_images/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE images ( 3 | id SERIAL PRIMARY KEY, 4 | width INTEGER NOT NULL, 5 | height INTEGER NOT NULL, 6 | file_id INTEGER REFERENCES files(id) ON DELETE CASCADE NOT NULL, 7 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 8 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 9 | ); 10 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154543_add_users/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE users; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154543_add_users/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE users ( 3 | id SERIAL PRIMARY KEY, 4 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 5 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 6 | ); 7 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154603_add_base_actors/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE base_actors; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154603_add_base_actors/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE base_actors ( 3 | id SERIAL PRIMARY KEY, 4 | display_name VARCHAR(80) NOT NULL, 5 | profile_url VARCHAR(2048) NOT NULL, 6 | inbox_url VARCHAR(2048) NOT NULL, 7 | outbox_url VARCHAR(2048) NOT NULL, 8 | local_user INTEGER REFERENCES users(id) ON DELETE CASCADE, 9 | follow_policy VARCHAR(8) NOT NULL, 10 | original_json JSONB NOT NULL, 11 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 12 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 13 | ); 14 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154616_add_base_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE base_posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154616_add_base_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE base_posts ( 3 | id SERIAL PRIMARY KEY, 4 | name VARCHAR(140), 5 | media_type VARCHAR(120) NOT NULL, 6 | posted_by INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 7 | icon INTEGER REFERENCES images(id) ON DELETE CASCADE, 8 | visibility VARCHAR(8) NOT NULL, 9 | original_json JSONB NOT NULL, 10 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 11 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 12 | ); 13 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154635_add_followers/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE followers; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154635_add_followers/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE followers ( 3 | id SERIAL PRIMARY KEY, 4 | follower INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 5 | follows INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154659_add_personas/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE personas; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154659_add_personas/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE personas ( 3 | id SERIAL PRIMARY KEY, 4 | default_visibility VARCHAR(8) NOT NULL, 5 | is_searchable BOOLEAN NOT NULL, 6 | avatar INTEGER REFERENCES images(id) ON DELETE CASCADE, 7 | shortname VARCHAR(80) NOT NULL, 8 | base_actor INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 9 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 10 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 11 | ); 12 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154746_add_links/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE links; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154746_add_links/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE links ( 3 | id SERIAL PRIMARY KEY, 4 | href VARCHAR(2048) NOT NULL, 5 | href_lang VARCHAR(8) NOT NULL, 6 | height INTEGER, 7 | width INTEGER, 8 | preview TEXT, 9 | base_post INTEGER REFERENCES base_posts(id) ON DELETE CASCADE NOT NULL, 10 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 11 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 12 | ); 13 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154755_add_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154755_add_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE posts ( 3 | id SERIAL PRIMARY KEY, 4 | content TEXT NOT NULL, 5 | source TEXT, 6 | base_post INTEGER REFERENCES base_posts(id) ON DELETE CASCADE NOT NULL, 7 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 8 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 9 | ); 10 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154811_add_media_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE media_posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154811_add_media_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE media_posts ( 3 | id SERIAL PRIMARY KEY, 4 | file_id INTEGER REFERENCES files(id) ON DELETE CASCADE NOT NULL, 5 | post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154838_add_comments/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE comments; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154838_add_comments/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE comments ( 3 | id SERIAL PRIMARY KEY, 4 | conversation INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL, 5 | parent INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL, 6 | post INTEGER REFERENCES posts(id) ON DELETE CASCADE NOT NULL, 7 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 8 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 9 | ); 10 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154903_add_reactions/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE reactions; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-04-154903_add_reactions/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE reactions ( 3 | id SERIAL PRIMARY KEY, 4 | reaction_type VARCHAR(10) NOT NULL, 5 | comment_id INTEGER REFERENCES comments(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-05-235333_add_emails/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE emails; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-05-235333_add_emails/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE emails ( 3 | id SERIAL PRIMARY KEY, 4 | email VARCHAR(256) UNIQUE NOT NULL, 5 | user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL, 6 | verified BOOLEAN NOT NULL DEFAULT FALSE, 7 | verification_token VARCHAR(256), 8 | confirmed_at TIMESTAMPTZ, 9 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 10 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 11 | ); 12 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-05-235511_add_email_to_users/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE users DROP COLUMN primary_email; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-05-235511_add_email_to_users/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE users ADD COLUMN primary_email INTEGER REFERENCES emails(id) ON DELETE CASCADE; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-06-221443_add_local_auth/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE local_auth; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-06-221443_add_local_auth/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE local_auth ( 3 | id SERIAL PRIMARY KEY, 4 | password VARCHAR(256) NOT NULL, 5 | user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-001818_add_timers/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE timers; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-001818_add_timers/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE timers ( 3 | id SERIAL PRIMARY KEY, 4 | fire_time TIMESTAMPTZ NOT NULL, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 7 | ); 8 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-001826_add_events/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE events; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-001826_add_events/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE events ( 3 | id SERIAL PRIMARY KEY, 4 | owner INTEGER REFERENCES personas(id) ON DELETE CASCADE NOT NULL, 5 | start_date INTEGER REFERENCES timers(id) ON DELETE CASCADE NOT NULL, 6 | end_date INTEGER REFERENCES timers(id) ON DELETE CASCADE NOT NULL, 7 | timezone VARCHAR(80) NOT NULL, 8 | title TEXT NOT NULL, 9 | description TEXT NOT NULL, 10 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 11 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 12 | ); 13 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-002440_add_event_notifications/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE event_notifications; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-002440_add_event_notifications/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE event_notifications ( 3 | id SERIAL PRIMARY KEY, 4 | event_id INTEGER REFERENCES events(id) ON DELETE CASCADE NOT NULL, 5 | timer_id INTEGER REFERENCES timers(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-211402_add_roles/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE roles; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-211402_add_roles/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE roles ( 3 | id SERIAL PRIMARY KEY, 4 | name VARCHAR(256) UNIQUE NOT NULL, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 7 | ); 8 | 9 | INSERT INTO roles (name, created_at) VALUES ('admin', 'now'); 10 | INSERT INTO roles (name, created_at) VALUES ('moderator', 'now'); 11 | INSERT INTO roles (name, created_at) VALUES ('verified', 'now'); 12 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-211409_add_user_roles/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE user_roles; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-211409_add_user_roles/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE user_roles ( 3 | id SERIAL PRIMARY KEY, 4 | user_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL, 5 | role_id INTEGER REFERENCES roles(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-212221_add_permissions/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE permissions; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-212221_add_permissions/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE permissions ( 3 | id SERIAL PRIMARY KEY, 4 | name VARCHAR(256) UNIQUE NOT NULL, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 7 | ); 8 | 9 | INSERT INTO permissions (name, created_at) VALUES ('follow-user', 'now'); 10 | INSERT INTO permissions (name, created_at) VALUES ('make-post', 'now'); 11 | INSERT INTO permissions (name, created_at) VALUES ('make-media-post', 'now'); 12 | INSERT INTO permissions (name, created_at) VALUES ('make-comment', 'now'); 13 | INSERT INTO permissions (name, created_at) VALUES ('configure-instance', 'now'); 14 | INSERT INTO permissions (name, created_at) VALUES ('ban-user', 'now'); 15 | INSERT INTO permissions (name, created_at) VALUES ('block-instance', 'now'); 16 | INSERT INTO permissions (name, created_at) VALUES ('grant-role', 'now'); 17 | INSERT INTO permissions (name, created_at) VALUES ('revoke-role', 'now'); 18 | INSERT INTO permissions (name, created_at) VALUES ('make-persona', 'now'); 19 | INSERT INTO permissions (name, created_at) VALUES ('manage-follow-requests', 'now'); 20 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-07-212434_add_role_permissions/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE role_permissions; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-08-214834_add_follow_requests/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE follow_requests; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-08-214834_add_follow_requests/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE follow_requests ( 3 | id SERIAL PRIMARY KEY, 4 | follower INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 5 | requested_follow INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012342_add_direct_posts/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE direct_posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012342_add_direct_posts/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE direct_posts ( 3 | id SERIAL PRIMARY KEY, 4 | base_post_id INTEGER REFERENCES base_posts(id) ON DELETE CASCADE NOT NULL, 5 | base_actor_id INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012357_add_groups/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE groups; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012357_add_groups/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE groups ( 3 | id SERIAL PRIMARY KEY, 4 | base_actor_id INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 5 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 6 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 7 | ); 8 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012407_add_group_base_actors/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DROP TABLE group_base_actors; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-14-012407_add_group_base_actors/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | CREATE TABLE group_base_actors ( 3 | id SERIAL PRIMARY KEY, 4 | group_id INTEGER REFERENCES groups(id) ON DELETE CASCADE NOT NULL, 5 | base_actor_id INTEGER REFERENCES base_actors(id) ON DELETE CASCADE NOT NULL, 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc'), 7 | updated_at TIMESTAMPTZ NOT NULL DEFAULT (now() at time zone 'utc') 8 | ); 9 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-18-010722_add_delete_switch_persona_permissions/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | DELETE FROM permissions WHERE name = 'switch-persona'; 3 | DELETE FROM permissions WHERE name = 'delete-persona'; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-18-010722_add_delete_switch_persona_permissions/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | INSERT INTO permissions (name, created_at) VALUES ('switch-persona', 'now'); 3 | INSERT INTO permissions (name, created_at) VALUES ('delete-persona', 'now'); 4 | 5 | INSERT INTO role_permissions (role_id, permission_id, created_at) VALUES ( 6 | (SELECT id FROM roles WHERE name = 'verified'), 7 | (SELECT id FROM permissions WHERE name = 'switch-persona'), 8 | 'now' 9 | ); 10 | INSERT INTO role_permissions (role_id, permission_id, created_at) VALUES ( 11 | (SELECT id FROM roles WHERE name = 'verified'), 12 | (SELECT id FROM permissions WHERE name = 'delete-persona'), 13 | 'now' 14 | ); 15 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004259_make_emails_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE emails DROP CONSTRAINT emails_unique_email; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004259_make_emails_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE emails ADD CONSTRAINT emails_unique_email UNIQUE (email); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004310_make_shortnames_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE personas DROP CONSTRAINT personas_unique_shortnames; 3 | ALTER TABLE personas DROP CONSTRAINT personas_unique_actors; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004310_make_shortnames_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE personas ADD CONSTRAINT personas_unique_shortnames UNIQUE (shortname); 3 | ALTER TABLE personas ADD CONSTRAINT personas_unique_actors UNIQUE (base_actor); 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004437_make_base_actor_urls_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_actors DROP CONSTRAINT base_actors_unique_profile_url; 3 | ALTER TABLE base_actors DROP CONSTRAINT base_actors_unique_inbox_url; 4 | ALTER TABLE base_actors DROP CONSTRAINT base_actors_unique_outbox_url; 5 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004437_make_base_actor_urls_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors ADD CONSTRAINT base_actors_unique_profile_url UNIQUE (profile_url); 3 | ALTER TABLE base_actors ADD CONSTRAINT base_actors_unique_inbox_url UNIQUE (inbox_url); 4 | ALTER TABLE base_actors ADD CONSTRAINT base_actors_unique_outbox_url UNIQUE (outbox_url); 5 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004542_make_permissions_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE permissions DROP CONSTRAINT permissions_unique_names; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004542_make_permissions_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE permissions ADD CONSTRAINT permissions_unique_names UNIQUE (name); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004549_make_roles_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE roles DROP CONSTRAINT roles_unique_names; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004549_make_roles_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE roles ADD CONSTRAINT roles_unique_names UNIQUE (name); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004642_make_file_path_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE files DROP CONSTRAINT files_unique_file_path; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004642_make_file_path_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE files ADD CONSTRAINT files_unique_file_path UNIQUE (file_path); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004702_make_follow_relation_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE followers DROP CONSTRAINT followers_unique_follower; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004702_make_follow_relation_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE followers ADD CONSTRAINT followers_unique_follower UNIQUE (follower, follows); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004711_make_group_relation_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE group_base_actors DROP CONSTRAINT group_base_actors_unique_group_relations; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004711_make_group_relation_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE group_base_actors ADD CONSTRAINT group_base_actors_unique_group_relations UNIQUE (group_id, base_actor_id); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004753_make_image_file_id_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE images DROP CONSTRAINT images_unique_file_ids; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004753_make_image_file_id_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE images ADD CONSTRAINT images_unique_file_ids UNIQUE (file_id); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004826_make_local_auth_user_id_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE local_auth DROP CONSTRAINT local_auth_unique_user_ids; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004826_make_local_auth_user_id_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE local_auth ADD CONSTRAINT local_auth_unique_user_ids UNIQUE (user_id); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004903_make_post_base_post_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE posts DROP CONSTRAINT posts_unique_base_posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004903_make_post_base_post_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE posts ADD CONSTRAINT posts_unique_base_posts UNIQUE (base_post); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004943_make_role_permission_relations_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE role_permissions DROP CONSTRAINT role_permissions_unique_relations; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004943_make_role_permission_relations_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE role_permissions ADD CONSTRAINT role_permissions_unique_relations UNIQUE (role_id, permission_id); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004953_make_user_role_relations_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE user_roles DROP CONSTRAINT user_roles_unique_relations; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-004953_make_user_role_relations_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE user_roles ADD CONSTRAINT user_roles_unique_relations UNIQUE (user_id, role_id); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-005022_make_user_primary_email_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE users DROP CONSTRAINT users_unique_primary_emails; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-005022_make_user_primary_email_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE users ADD CONSTRAINT users_unique_primary_emails UNIQUE (primary_email); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-005122_make_comments_post_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE comments DROP CONSTRAINT comments_unique_posts; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-005122_make_comments_post_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE comments ADD CONSTRAINT comments_unique_posts UNIQUE (post); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-010016_make_follow_requests_unique/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE follow_requests DROP CONSTRAINT follow_requests_unique_follow_requests; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-04-20-010016_make_follow_requests_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE follow_requests ADD CONSTRAINT follow_requests_unique_follow_requests UNIQUE (follower, requested_follow); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-10-29-022958_remove_redundant_email_constraint/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE emails ADD CONSTRAINT emails_unique_email UNIQUE (email); 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2018-10-29-022958_remove_redundant_email_constraint/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE emails DROP CONSTRAINT emails_unique_email; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-200142_add_keys_to_base_actor/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_actors 3 | DROP COLUMN private_key_der, 4 | DROP COLUMN public_key_der; 5 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-200142_add_keys_to_base_actor/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors 3 | ADD COLUMN private_key_der BYTEA NOT NULL, 4 | ADD COLUMN public_key_der BYTEA NOT NULL; 5 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-200751_remove_json_stores/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_posts ADD COLUMN original_json JSONB; 3 | ALTER TABLE base_actors ADD COLUMN original_json JSONB; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-200751_remove_json_stores/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors DROP COLUMN original_json; 3 | ALTER TABLE base_posts DROP COLUMN original_json; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-214817_add_local_uuid/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_posts 3 | DROP COLUMN local_uuid; 4 | 5 | ALTER TABLE base_actors 6 | DROP COLUMN local_uuid; 7 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-12-214817_add_local_uuid/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors 3 | ADD COLUMN local_uuid UUID; 4 | 5 | ALTER TABLE base_posts 6 | ADD COLUMN local_uuid UUID; 7 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-13-035602_add-primary-persona/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE users 3 | DROP COLUMN primary_persona; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-13-035602_add-primary-persona/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE users 3 | ADD COLUMN primary_persona INTEGER REFERENCES personas(id) ON DELETE CASCADE; 4 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-18-211319_make_private_key_nullable/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_actors ALTER COLUMN private_key_der SET NOT NULL; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-18-211319_make_private_key_nullable/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors ALTER COLUMN private_key_der DROP NOT NULL; 3 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-18-212737_add_activitypub_ids/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | ALTER TABLE base_posts 3 | DROP COLUMN activitypub_id; 4 | 5 | ALTER TABLE base_actors 6 | DROP COLUMN activitypub_id; 7 | -------------------------------------------------------------------------------- /aardwolf-models/migrations/2019-01-18-212737_add_activitypub_ids/up.sql: -------------------------------------------------------------------------------- 1 | -- Your SQL goes here 2 | ALTER TABLE base_actors 3 | ADD COLUMN activitypub_id VARCHAR(300) UNIQUE NOT NULL; 4 | 5 | ALTER TABLE base_posts 6 | ADD COLUMN activitypub_id VARCHAR(300) UNIQUE NOT NULL; 7 | -------------------------------------------------------------------------------- /aardwolf-models/src/base_actor/group.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | use diesel::{self, pg::PgConnection}; 3 | 4 | pub mod group_base_actor; 5 | 6 | use crate::{base_actor::BaseActor, schema::groups}; 7 | 8 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 9 | #[diesel(table_name = groups)] 10 | pub struct Group { 11 | id: i32, 12 | base_actor_id: i32, // foreign key to BaseActor 13 | created_at: DateTime, 14 | updated_at: DateTime, 15 | } 16 | 17 | impl Group { 18 | pub fn id(&self) -> i32 { 19 | self.id 20 | } 21 | 22 | pub fn base_actor_id(&self) -> i32 { 23 | self.base_actor_id 24 | } 25 | 26 | pub fn created_at(&self) -> DateTime { 27 | self.created_at 28 | } 29 | 30 | pub fn updated_at(&self) -> DateTime { 31 | self.updated_at 32 | } 33 | } 34 | 35 | #[derive(Insertable)] 36 | #[diesel(table_name = groups)] 37 | pub struct NewGroup { 38 | base_actor_id: i32, 39 | } 40 | 41 | impl NewGroup { 42 | pub fn insert(self, conn: &mut PgConnection) -> Result { 43 | use diesel::prelude::*; 44 | 45 | diesel::insert_into(groups::table) 46 | .values(&self) 47 | .get_result(conn) 48 | } 49 | 50 | pub fn new(base_actor: &BaseActor) -> Self { 51 | NewGroup { 52 | base_actor_id: base_actor.id(), 53 | } 54 | } 55 | } 56 | 57 | #[cfg(test)] 58 | mod tests { 59 | use crate::test_helper::*; 60 | 61 | #[test] 62 | fn create_group() { 63 | with_connection(|conn| { 64 | let group_base = make_base_actor(conn)?; 65 | let group = make_group(conn, &group_base); 66 | 67 | assert!(group.is_ok()); 68 | 69 | Ok(()) 70 | }) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /aardwolf-models/src/file/image.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | 3 | use crate::{file::File, schema::images}; 4 | 5 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 6 | #[diesel(table_name = images)] 7 | pub struct Image { 8 | id: i32, 9 | width: u32, 10 | height: u32, 11 | file_id: i32, // foreign key to File 12 | created_at: DateTime, 13 | updated_at: DateTime, 14 | } 15 | 16 | impl Image { 17 | pub fn id(&self) -> i32 { 18 | self.id 19 | } 20 | 21 | pub fn width(&self) -> u32 { 22 | self.width 23 | } 24 | 25 | pub fn height(&self) -> u32 { 26 | self.height 27 | } 28 | 29 | pub fn file_id(&self) -> i32 { 30 | self.file_id 31 | } 32 | 33 | pub fn created_at(&self) -> DateTime { 34 | self.created_at 35 | } 36 | 37 | pub fn updated_at(&self) -> DateTime { 38 | self.updated_at 39 | } 40 | } 41 | 42 | #[derive(Insertable)] 43 | #[diesel(table_name = images)] 44 | pub struct NewImage { 45 | width: i32, 46 | height: i32, 47 | file_id: i32, 48 | } 49 | 50 | impl NewImage { 51 | pub fn new(file: &File, width: u32, height: u32) -> Self { 52 | NewImage { 53 | width: width as i32, 54 | height: height as i32, 55 | file_id: file.id(), 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /aardwolf-models/src/generate_urls.rs: -------------------------------------------------------------------------------- 1 | use uuid::Uuid; 2 | 3 | use crate::{base_actor::BaseActor, sql_types::Url}; 4 | 5 | pub trait GenerateUrls { 6 | fn activitypub_id(&self, uuid: &Uuid) -> String; 7 | fn profile_url(&self, uuid: &Uuid) -> Url; 8 | fn inbox_url(&self, uuid: &Uuid) -> Url; 9 | fn outbox_url(&self, uuid: &Uuid) -> Url; 10 | 11 | fn post_id(&self, base_actor: &BaseActor, uuid: &Uuid) -> String; 12 | fn post_url(&self, base_actor: &BaseActor, uuid: &Uuid) -> Url; 13 | } 14 | -------------------------------------------------------------------------------- /aardwolf-models/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate diesel; 3 | 4 | pub mod base_actor; 5 | pub mod base_post; 6 | pub mod file; 7 | pub mod generate_urls; 8 | pub mod link; 9 | pub mod schema; 10 | pub mod sql_types; 11 | pub mod timer; 12 | pub mod user; 13 | 14 | #[cfg(any(test, feature = "test"))] 15 | pub mod test_helper; 16 | -------------------------------------------------------------------------------- /aardwolf-models/src/sql_types.rs: -------------------------------------------------------------------------------- 1 | pub mod follow_policy; 2 | pub mod lang; 3 | pub mod mime; 4 | pub mod permission; 5 | pub mod post_visibility; 6 | pub mod reaction_type; 7 | pub mod role; 8 | pub mod timezone; 9 | pub mod url; 10 | 11 | pub use self::{ 12 | follow_policy::FollowPolicy, lang::Lang, mime::Mime, permission::Permission, 13 | post_visibility::PostVisibility, reaction_type::ReactionType, role::Role, timezone::Timezone, 14 | url::Url, 15 | }; 16 | -------------------------------------------------------------------------------- /aardwolf-models/src/sql_types/lang.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error as StdError; 2 | 3 | use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; 4 | use strum_macros::{Display, EnumString, IntoStaticStr}; 5 | 6 | #[derive( 7 | AsExpression, 8 | Clone, 9 | Copy, 10 | Debug, 11 | Display, 12 | EnumString, 13 | Eq, 14 | FromSqlRow, 15 | Hash, 16 | IntoStaticStr, 17 | PartialEq, 18 | )] 19 | #[diesel(sql_type = Text)] 20 | pub enum Lang { 21 | EnUs, 22 | EnUk, 23 | EnAu, 24 | } 25 | 26 | impl serialize::ToSql for Lang 27 | where 28 | DB: Backend, 29 | str: serialize::ToSql, 30 | { 31 | fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, DB>) -> serialize::Result { 32 | let name: &'static str = self.into(); 33 | 34 | name.to_sql(out) 35 | } 36 | } 37 | 38 | impl deserialize::FromSql for Lang 39 | where 40 | DB: Backend, 41 | *const str: deserialize::FromSql, 42 | { 43 | fn from_sql(bytes: ::RawValue<'_>) -> deserialize::Result { 44 | deserialize::FromSql::::from_sql(bytes).and_then(|string: String| { 45 | string 46 | .parse::() 47 | .map_err(|e| Box::new(e) as Box) 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /aardwolf-models/src/sql_types/reaction_type.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error as StdError; 2 | 3 | use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; 4 | use strum_macros::{Display, EnumString, IntoStaticStr}; 5 | 6 | #[derive( 7 | AsExpression, 8 | Clone, 9 | Copy, 10 | Debug, 11 | Display, 12 | EnumString, 13 | Eq, 14 | FromSqlRow, 15 | Hash, 16 | IntoStaticStr, 17 | PartialEq, 18 | )] 19 | #[diesel(sql_type = Text)] 20 | pub enum ReactionType { 21 | #[strum(serialize = "LIKE")] 22 | Like, 23 | #[strum(serialize = "DISLIKE")] 24 | Dislike, 25 | #[strum(serialize = "SEEN")] 26 | Seen, 27 | } 28 | 29 | impl serialize::ToSql for ReactionType 30 | where 31 | DB: Backend, 32 | str: serialize::ToSql, 33 | { 34 | fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, DB>) -> serialize::Result { 35 | let name: &'static str = self.into(); 36 | 37 | name.to_sql(out) 38 | } 39 | } 40 | 41 | impl deserialize::FromSql for ReactionType 42 | where 43 | DB: Backend, 44 | *const str: deserialize::FromSql, 45 | { 46 | fn from_sql(bytes: ::RawValue<'_>) -> deserialize::Result { 47 | deserialize::FromSql::::from_sql(bytes).and_then(|string: String| { 48 | string 49 | .parse::() 50 | .map_err(|e| Box::new(e) as Box) 51 | }) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /aardwolf-models/src/sql_types/role.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error as StdError; 2 | 3 | use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; 4 | use strum_macros::{Display, EnumString, IntoStaticStr}; 5 | 6 | #[derive( 7 | AsExpression, 8 | Clone, 9 | Copy, 10 | Debug, 11 | Display, 12 | EnumString, 13 | Eq, 14 | FromSqlRow, 15 | Hash, 16 | IntoStaticStr, 17 | PartialEq, 18 | )] 19 | #[diesel(sql_type = Text)] 20 | pub enum Role { 21 | #[strum(serialize = "verified")] 22 | Verified, 23 | #[strum(serialize = "moderator")] 24 | Moderator, 25 | #[strum(serialize = "admin")] 26 | Admin, 27 | } 28 | 29 | impl serialize::ToSql for Role 30 | where 31 | DB: Backend, 32 | str: serialize::ToSql, 33 | { 34 | fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, DB>) -> serialize::Result { 35 | let name: &'static str = self.into(); 36 | 37 | name.to_sql(out) 38 | } 39 | } 40 | 41 | impl deserialize::FromSql for Role 42 | where 43 | DB: Backend, 44 | *const str: deserialize::FromSql, 45 | { 46 | fn from_sql(bytes: ::RawValue<'_>) -> deserialize::Result { 47 | deserialize::FromSql::::from_sql(bytes).and_then(|string: String| { 48 | string 49 | .parse::() 50 | .map_err(|e| Box::new(e) as Box) 51 | }) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /aardwolf-models/src/sql_types/url.rs: -------------------------------------------------------------------------------- 1 | use std::{error::Error as StdError, str::FromStr}; 2 | 3 | use diesel::{backend::Backend, deserialize, serialize, sql_types::Text}; 4 | use url::Url as OrigUrl; 5 | 6 | #[derive(AsExpression, Clone, Debug, FromSqlRow)] 7 | #[diesel(sql_type = Text)] 8 | pub struct Url(pub OrigUrl); 9 | 10 | impl serialize::ToSql for Url 11 | where 12 | DB: Backend, 13 | str: serialize::ToSql, 14 | { 15 | fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, DB>) -> serialize::Result { 16 | self.0.as_str().to_sql(out) 17 | } 18 | } 19 | 20 | impl deserialize::FromSql for Url 21 | where 22 | DB: Backend, 23 | *const str: deserialize::FromSql, 24 | { 25 | fn from_sql(bytes: ::RawValue<'_>) -> deserialize::Result { 26 | deserialize::FromSql::::from_sql(bytes).and_then(|s: String| { 27 | s.parse() 28 | .map(Url) 29 | .map_err(|e| Box::new(e) as Box) 30 | }) 31 | } 32 | } 33 | 34 | impl From for Url { 35 | fn from(u: OrigUrl) -> Self { 36 | Url(u) 37 | } 38 | } 39 | 40 | impl FromStr for Url { 41 | type Err = ::Err; 42 | 43 | fn from_str(s: &str) -> Result { 44 | FromStr::from_str(s).map(Url) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /aardwolf-models/src/timer.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | use diesel::{self, pg::PgConnection}; 3 | 4 | pub mod event; 5 | pub mod event_notification; 6 | 7 | use crate::schema::timers; 8 | 9 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 10 | #[diesel(table_name = timers)] 11 | pub struct Timer { 12 | id: i32, 13 | fire_time: DateTime, 14 | created_at: DateTime, 15 | updated_at: DateTime, 16 | } 17 | 18 | impl Timer { 19 | pub fn id(&self) -> i32 { 20 | self.id 21 | } 22 | 23 | pub fn fire_time(&self) -> DateTime { 24 | self.fire_time 25 | } 26 | 27 | pub fn created_at(&self) -> DateTime { 28 | self.created_at 29 | } 30 | 31 | pub fn updated_at(&self) -> DateTime { 32 | self.updated_at 33 | } 34 | } 35 | 36 | #[derive(Insertable)] 37 | #[diesel(table_name = timers)] 38 | pub struct NewTimer { 39 | fire_time: DateTime, 40 | } 41 | 42 | impl NewTimer { 43 | pub fn insert(self, conn: &mut PgConnection) -> Result { 44 | use diesel::prelude::*; 45 | 46 | diesel::insert_into(timers::table) 47 | .values(&self) 48 | .get_result(conn) 49 | } 50 | 51 | pub fn new(fire_time: DateTime) -> Self { 52 | NewTimer { fire_time } 53 | } 54 | } 55 | 56 | #[cfg(test)] 57 | mod tests { 58 | use crate::test_helper::*; 59 | 60 | #[test] 61 | fn create_timer() { 62 | with_connection(|conn| { 63 | let _ = make_timer(conn); 64 | 65 | Ok(()) 66 | }) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /aardwolf-models/src/user/role.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | 3 | pub mod permission; 4 | pub mod role_permission; 5 | pub mod user_role; 6 | 7 | use crate::{schema::roles, sql_types::Role as RoleSql}; 8 | 9 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 10 | #[diesel(table_name = roles)] 11 | pub struct Role { 12 | id: i32, 13 | name: RoleSql, 14 | created_at: DateTime, 15 | updated_at: DateTime, 16 | } 17 | 18 | impl Role { 19 | pub fn id(&self) -> i32 { 20 | self.id 21 | } 22 | 23 | pub fn name(&self) -> RoleSql { 24 | self.name 25 | } 26 | 27 | pub fn created_at(&self) -> DateTime { 28 | self.created_at 29 | } 30 | 31 | pub fn updated_at(&self) -> DateTime { 32 | self.updated_at 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aardwolf-models/src/user/role/permission.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | 3 | use crate::{schema::permissions, sql_types::Permission as PermissionSql}; 4 | 5 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 6 | #[diesel(table_name = permissions)] 7 | pub struct Permission { 8 | id: i32, 9 | name: PermissionSql, 10 | created_at: DateTime, 11 | updated_at: DateTime, 12 | } 13 | 14 | impl Permission { 15 | pub fn id(&self) -> i32 { 16 | self.id 17 | } 18 | 19 | pub fn name(&self) -> PermissionSql { 20 | self.name 21 | } 22 | 23 | pub fn created_at(&self) -> DateTime { 24 | self.created_at 25 | } 26 | 27 | pub fn updated_at(&self) -> DateTime { 28 | self.updated_at 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aardwolf-models/src/user/role/role_permission.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | 3 | use crate::schema::role_permissions; 4 | 5 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 6 | #[diesel(table_name = role_permissions)] 7 | pub struct RolePermission { 8 | id: i32, 9 | role_id: i32, // foreign key to Role 10 | permission_id: i32, // foreign key to Permission 11 | created_at: DateTime, 12 | updated_at: DateTime, 13 | } 14 | 15 | impl RolePermission { 16 | pub fn id(&self) -> i32 { 17 | self.id 18 | } 19 | 20 | pub fn role_id(&self) -> i32 { 21 | self.role_id 22 | } 23 | 24 | pub fn permission_id(&self) -> i32 { 25 | self.permission_id 26 | } 27 | 28 | pub fn created_at(&self) -> DateTime { 29 | self.created_at 30 | } 31 | 32 | pub fn updated_at(&self) -> DateTime { 33 | self.updated_at 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aardwolf-models/src/user/role/user_role.rs: -------------------------------------------------------------------------------- 1 | use chrono::{offset::Utc, DateTime}; 2 | 3 | use crate::schema::user_roles; 4 | 5 | #[derive(Debug, Identifiable, Queryable, QueryableByName)] 6 | #[diesel(table_name = user_roles)] 7 | pub struct UserRole { 8 | id: i32, 9 | user_id: i32, // foreign key to User 10 | role_id: i32, // foreign key to Role 11 | created_at: DateTime, 12 | updated_at: DateTime, 13 | } 14 | 15 | impl UserRole { 16 | pub fn id(&self) -> i32 { 17 | self.id 18 | } 19 | 20 | pub fn user_id(&self) -> i32 { 21 | self.user_id 22 | } 23 | 24 | pub fn role_id(&self) -> i32 { 25 | self.role_id 26 | } 27 | 28 | pub fn created_at(&self) -> DateTime { 29 | self.created_at 30 | } 31 | 32 | pub fn updated_at(&self) -> DateTime { 33 | self.updated_at 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aardwolf-templates/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-templates" 3 | version = "0.1.0" 4 | authors = ["asonix "] 5 | edition = "2021" 6 | build = "build.rs" 7 | 8 | [build-dependencies] 9 | ructe = "0.18.2" 10 | 11 | [dependencies] 12 | gettext = "0.4.0" 13 | gettext-macros = "0.6.1" 14 | rust-i18n = { version = "3.1.2", features = ["log-miss-tr"] } 15 | log = "0.4.17" 16 | 17 | [dependencies.aardwolf-types] 18 | version = "0.1" 19 | path = "../aardwolf-types" 20 | 21 | [dependencies.aardwolf-models] 22 | version = "0.1" 23 | path = "../aardwolf-models" 24 | 25 | [package.metadata.i18n] 26 | base_path = "../locales" 27 | -------------------------------------------------------------------------------- /aardwolf-templates/build.rs: -------------------------------------------------------------------------------- 1 | use ructe::{Result, Ructe}; 2 | 3 | fn main() -> Result<()> { 4 | let metadata = std::env::var("CARGO_PKG_METADATA").unwrap_or_default(); 5 | println!("cargo:rerun-if-changed=Cargo.toml"); 6 | println!("cargo:warning=Metadata: {}", metadata); 7 | 8 | // Initialize Ructe from the environment 9 | let mut ructe = Ructe::from_env()?; 10 | 11 | // Compile templates located in the "templates" directory 12 | ructe.compile_templates("templates")?; 13 | 14 | // Instruct Cargo to rerun the build script if any files in the "templates" directory change 15 | println!("cargo:rerun-if-changed=templates"); 16 | 17 | // Additional configuration can be added here if needed 18 | 19 | Ok(()) 20 | } 21 | -------------------------------------------------------------------------------- /aardwolf-templates/src/asides/mod.rs: -------------------------------------------------------------------------------- 1 | mod settings; 2 | mod shortcuts; 3 | 4 | pub use self::{settings::Settings, shortcuts::Shortcuts}; 5 | -------------------------------------------------------------------------------- /aardwolf-templates/src/asides/settings.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct Settings<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/asides/shortcuts.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct Shortcuts<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | 9 | impl<'a> Shortcuts<'a> { 10 | pub fn new(catalog: &'a Catalog, profile_link: &'a str, username: &'a str) -> Self { 11 | Self { 12 | catalog, 13 | profile_link, 14 | username, 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aardwolf-templates/src/containers/calendar.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct Calendar<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/containers/mod.rs: -------------------------------------------------------------------------------- 1 | mod calendar; 2 | mod preferences; 3 | mod profile_edit; 4 | mod profile_view; 5 | 6 | pub use self::{calendar::*, preferences::*, profile_edit::*, profile_view::*}; 7 | -------------------------------------------------------------------------------- /aardwolf-templates/src/containers/preferences.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct Preferences<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/containers/profile_edit.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct ProfileEdit<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/containers/profile_view.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct ProfileView<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) profile_link: &'a str, 6 | pub(crate) username: &'a str, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/alert.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] 2 | pub enum AlertKind { 3 | Error, 4 | #[allow(dead_code)] 5 | Warning, 6 | #[allow(dead_code)] 7 | Info, 8 | } 9 | 10 | impl std::fmt::Display for AlertKind { 11 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 12 | let s = match *self { 13 | AlertKind::Error => "error", 14 | AlertKind::Warning => "warning", 15 | AlertKind::Info => "info", 16 | }; 17 | 18 | write!(f, "{}", s) 19 | } 20 | } 21 | #[derive(Debug)] 22 | pub struct Alert { 23 | pub(crate) kind: AlertKind, 24 | pub(crate) message: String, 25 | } 26 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/input_text.rs: -------------------------------------------------------------------------------- 1 | use super::input::Input; 2 | 3 | #[derive(Debug)] 4 | pub struct InputText<'a> { 5 | pub name: &'a str, 6 | pub label: String, 7 | pub placeholder: Option, 8 | pub icon: Option<&'a str>, 9 | pub value: &'a str, 10 | pub error: Option, 11 | } 12 | 13 | impl<'a> Default for InputText<'a> { 14 | fn default() -> Self { 15 | Self { 16 | name: "", 17 | label: String::new(), 18 | placeholder: None, 19 | icon: None, 20 | value: "", 21 | error: None, 22 | } 23 | } 24 | } 25 | 26 | impl<'a> InputText<'a> { 27 | pub fn new( 28 | name: &'a str, 29 | label: Option<&'a str>, 30 | value: Option<&'a str>, 31 | error: Option<&'a str>, 32 | ) -> Self { 33 | Self { 34 | name, 35 | label: label.map_or_else(String::new, Into::into), 36 | value: value.unwrap_or(""), 37 | error: error.map(Into::into), 38 | ..Default::default() 39 | } 40 | } 41 | } 42 | 43 | impl<'a> From<&'a InputText<'a>> for Input<'a> { 44 | fn from(input_text: &'a InputText<'a>) -> Self { 45 | Self { 46 | kind: "text", 47 | name: input_text.name, 48 | label: Some(input_text.label.clone()), 49 | placeholder: input_text.placeholder.clone(), 50 | icon: input_text.icon, 51 | value: input_text.value, 52 | error: input_text.error.clone(), 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/input_textarea.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub struct InputTextarea<'a> { 3 | pub name: &'a str, 4 | pub label: Option, 5 | pub icon: Option<&'a str>, 6 | pub placeholder: Option, 7 | pub value: &'a str, 8 | pub error: Option, 9 | } 10 | 11 | impl<'a> Default for InputTextarea<'a> { 12 | fn default() -> Self { 13 | Self { 14 | name: "", 15 | label: None, 16 | icon: None, 17 | placeholder: None, 18 | value: "", 19 | error: None, 20 | } 21 | } 22 | } 23 | 24 | impl<'a> InputTextarea<'a> { 25 | pub fn new( 26 | name: &'a str, 27 | label: Option<&'a str>, 28 | value: Option<&'a str>, 29 | error: Option<&'a str>, 30 | ) -> Self { 31 | Self { 32 | name, 33 | label: label.map(ToString::to_string), 34 | value: value.unwrap_or_default(), 35 | error: error.map(ToString::to_string), 36 | ..Default::default() 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/lang_dropdown.rs: -------------------------------------------------------------------------------- 1 | pub struct LangDropdown {} 2 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod alert; 2 | pub mod input; 3 | pub mod input_select; 4 | pub mod input_text; 5 | pub mod input_textarea; 6 | pub mod lang_dropdown; 7 | pub mod notification_content; 8 | pub mod notification_dropdown; 9 | pub mod search_bar; 10 | 11 | pub use lang_dropdown::LangDropdown; 12 | pub use notification_dropdown::NotificationDropdown; 13 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/notification_content.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | /// A struct representing the content of a notification. 4 | pub struct NotificationContent<'a> { 5 | /// The translation catalog to use for translating the notification content. 6 | pub catalog: &'a Catalog, 7 | } 8 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/notification_dropdown.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | /// A dropdown menu for displaying notifications. 4 | #[derive(Debug)] 5 | pub struct NotificationDropdown<'a> { 6 | /// The gettext catalog for translating strings. 7 | catalog: &'a Catalog, 8 | } 9 | -------------------------------------------------------------------------------- /aardwolf-templates/src/elements/search_bar.rs: -------------------------------------------------------------------------------- 1 | pub struct SearchBar {} 2 | -------------------------------------------------------------------------------- /aardwolf-templates/src/error/http_error.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct Settings<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | pub(crate) http_error: &'a str, 6 | } 7 | -------------------------------------------------------------------------------- /aardwolf-templates/src/error/mod.rs: -------------------------------------------------------------------------------- 1 | mod http_error; 2 | -------------------------------------------------------------------------------- /aardwolf-templates/src/home/feed.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | use std::io::{Result, Write}; 3 | 4 | use crate::Renderable; 5 | 6 | pub struct Feed<'a> { 7 | pub(crate) catalog: &'a Catalog, 8 | } 9 | 10 | impl<'a> Feed<'a> { 11 | pub fn new(catalog: &'a Catalog) -> Self { 12 | Feed { catalog } 13 | } 14 | } 15 | 16 | impl<'a> Renderable for Feed<'a> { 17 | fn render(&self, writer: &mut dyn Write) -> Result<()> { 18 | write!( 19 | writer, 20 | "{}", 21 | self.catalog.gettext("This is the feed template") 22 | )?; 23 | writer.flush()?; // Ensure the writer is flushed after writing 24 | Ok(()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aardwolf-templates/src/home/home.rs: -------------------------------------------------------------------------------- 1 | use aardwolf_types::forms::posts::{PostCreationFormState, ValidatePostCreationError}; 2 | use gettext::Catalog; 3 | 4 | use crate::{ 5 | asides::Shortcuts, 6 | home::{feed::Feed, nav_top::NavTop}, 7 | posts::NewPost, 8 | Renderable, 9 | }; 10 | use crate::sign_up::SignUp; 11 | 12 | pub struct Home<'a> { 13 | pub catalog: &'a Catalog, 14 | pub shortcuts: Shortcuts<'a>, 15 | pub nav_top: NavTop<'a>, 16 | pub feed: Feed<'a>, 17 | pub new_post: NewPost<'a>, 18 | } 19 | 20 | impl<'a> Home<'a> { 21 | pub fn new( 22 | catalog: &'a Catalog, 23 | profile_link: &'a str, 24 | username: &'a str, 25 | csrf_token: &'a str, 26 | form_state: &'a PostCreationFormState, 27 | validation_error: Option<&'a ValidatePostCreationError>, 28 | ) -> Self { 29 | Self { 30 | catalog, 31 | shortcuts: Shortcuts::new(catalog, profile_link, username), 32 | nav_top: NavTop::new(catalog), 33 | feed: Feed::new(catalog), 34 | new_post: NewPost::new(catalog, csrf_token, form_state, validation_error), 35 | } 36 | } 37 | } 38 | 39 | impl<'a> Renderable for Home<'a> { 40 | fn render(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()> { 41 | Ok(()) // return a successful Result 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /aardwolf-templates/src/home/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod feed; 2 | pub mod home; 3 | pub mod nav_top; 4 | -------------------------------------------------------------------------------- /aardwolf-templates/src/home/nav_top.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | pub struct NavTop<'a> { 4 | pub(crate) catalog: &'a Catalog, 5 | } 6 | 7 | impl<'a> NavTop<'a> { 8 | pub fn new(catalog: &'a Catalog) -> Self { 9 | Self { catalog } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aardwolf-templates/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Load I18n macro, for allow you to use `t!` macro in anywhere. 2 | #[macro_use] 3 | extern crate rust_i18n; 4 | i18n!("locales", fallback = "en"); 5 | #[derive(Debug, Clone)] 6 | pub struct Translations { 7 | locale: Cow<'static, str>, 8 | } 9 | 10 | impl Translations { 11 | pub fn new(locale: impl Into>) -> Self { 12 | Self { 13 | locale: locale.into(), 14 | } 15 | } 16 | 17 | pub fn get(&self, key: &str) -> Cow<'static, str> { 18 | rust_i18n::t!(key, locale = self.locale.as_ref()) 19 | .unwrap_or_else(|e| { 20 | eprintln!("Failed to translate key '{}': {}", key, e); 21 | key 22 | }) 23 | .into() 24 | } 25 | 26 | pub fn get_or_fallback(&self, key: &str, default: &str) -> Cow<'static, str> { 27 | let translation = self.get(key); 28 | if translation == key { 29 | Cow::from(default.to_string()) 30 | } else { 31 | translation 32 | } 33 | } 34 | 35 | pub fn locale(&self) -> &str { 36 | &self.locale 37 | } 38 | } 39 | 40 | pub mod asides; 41 | pub mod containers; 42 | pub mod elements; 43 | pub mod error; 44 | pub mod first_login; 45 | pub mod home; 46 | pub mod posts; 47 | pub mod sign_in; 48 | pub mod sign_up; 49 | 50 | pub trait Renderable { 51 | fn render(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()>; 52 | } 53 | -------------------------------------------------------------------------------- /aardwolf-templates/src/posts/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod new_post; 2 | pub mod reply_post; 3 | 4 | pub use self::{new_post::NewPost, reply_post::ReplyPost}; 5 | -------------------------------------------------------------------------------- /aardwolf-templates/src/posts/reply_post.rs: -------------------------------------------------------------------------------- 1 | use gettext::Catalog; 2 | 3 | use crate::elements::{ 4 | alert::Alert, input_select::InputSelect, input_text::InputText, input_textarea::InputTextarea, 5 | }; 6 | 7 | #[derive(Debug)] 8 | pub struct ReplyPost<'a> { 9 | pub catalog: &'a Catalog, 10 | pub csrf_token: &'a str, 11 | pub alert: Option, 12 | pub author: &'a str, 13 | pub source: InputTextarea<'a>, 14 | pub visibility: InputSelect<'a>, 15 | pub title: InputText<'a>, 16 | } 17 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/asides/settings.rs.html: -------------------------------------------------------------------------------- 1 | @use gettext::Catalog; 2 | @use rust_i18n::t; 3 | 4 | @(catalog: &Catalog) 5 | 6 | 32 | 33 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/asides/shortcuts.rs.html: -------------------------------------------------------------------------------- 1 | @use super::elements::icon; 2 | 3 | @(shortcuts: &Shortcuts) 4 | 5 | 30 | 31 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/base.rs.html: -------------------------------------------------------------------------------- 1 | @use super::{footer, html_head}; 2 | 3 | @(catalog: &Catalog, title: &str, page_content: Content) 4 | 5 | 6 | 7 | @:html_head(&catalog, title) 8 | 9 | @:page_content() 10 | @:footer(&catalog) 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/containers/calendar.rs.html: -------------------------------------------------------------------------------- 1 | @use gettext::Catalog; 2 | 3 | @(catalog: &Catalog) 4 | 5 |
6 | 7 |

Hey check it out! There is a Calendar with date/time pickers on Creative Bulma!!
8 | https://creativebulma.net/product/calendar 9 | 10 |

11 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/alert.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{Alert, AlertKind, templates::elements::icon}; 2 | 3 | @(alert: &Alert) 4 | 5 |
"warning", 8 | AlertKind::Error => "error", 9 | AlertKind::Success => "success", 10 | }"> 11 | 12 |
13 | @:icon(match alert.kind { 14 | AlertKind::Info => "info-circle", 15 | AlertKind::Warning => "exclamation-triangle", 16 | AlertKind::Error => "exclamation-circle", 17 | AlertKind::Success => "check-circle", 18 | }) 19 |
20 | 21 |
22 | @alert.message 23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/icon.rs.html: -------------------------------------------------------------------------------- 1 | @( 2 | icon_class: &str 3 | ) 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{Input, templates::elements::icon}; 2 | 3 | @(input: &Input) 4 | 5 |
6 | 14 |
15 | @if let Some(ref placeholder) = input.placeholder { 16 | 17 | } else { 18 | 19 | } 20 |
21 |
22 | @if let Some(ref error) = input.error { 23 | @error 24 | } 25 |
26 |
27 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_checkbox.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{InputCheckbox, templates::elements::icon}; 2 | 3 | @(checkbox: &InputCheckbox) 4 | 5 |
6 | 12 |
13 | @if input.checked { 14 | 15 | } else { 16 | 17 | } 18 |
19 |
20 | @if let Some(ref error) = input.error { 21 | @error 22 | } 23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_email.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::templates::elements::input; 2 | 3 | @(input_email: &InputEmail) 4 | 5 | @:input(input_email) 6 | 7 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_password.rs.html: -------------------------------------------------------------------------------- 1 | @use gettext::Catalog; 2 | @use rust_i18n::t; 3 | @use crate::{InputPassword, templates::elements::input}; 4 | 5 | @(input_password: &InputPassword, catalog: &Catalog) 6 | 7 | @:input(&input_password.into()) 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_password_confirm.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::templates::elements::input; 2 | 3 | @(input_password_confirm: &InputPasswordConfirm) 4 | 5 | @:input(input_password_confirm) 6 | 7 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_select.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::InputSelect; 2 | 3 | @(input: &InputSelect) 4 | 5 |
6 | 9 |
10 | 23 |
24 |
25 | @if let Some(ref error) = input.error { 26 | @error 27 | } 28 |
29 |
30 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_text.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{InputText, templates::elements::input}; 2 | 3 | @(input_text: &InputText) 4 | 5 | @:input(&input_text.into()) 6 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/input_textarea.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{InputTextarea, templates::elements::icon}; 2 | 3 | @(input: &InputTextarea) 4 | 5 |
6 | 14 |
15 | @if let Some(ref placeholder) = input.placeholder { 16 | 17 | } else { 18 | 19 | } 20 |
21 |
22 | @if let Some(ref error) = input.error { 23 | @error 24 | } 25 |
26 |
27 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/lang_dropdown.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::elements::LangDropdown; 2 | 3 | @(lang_dropdown: &LangDropdown) 4 | 5 |
6 |

7 |

8 | 17 |
18 |

19 |
20 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/notification_content.rs.html: -------------------------------------------------------------------------------- 1 | @use rust_i18n::t; 2 | @use crate::elements::NotificationContent; 3 | 4 | @(notification_content: &NotificationContent) 5 | 6 |
7 |
8 |
9 |
10 | 11 |
12 |
13 |
14 |
15 |

16 | {{ notification_content.author_name }} 17 | @{{ notification_content.author_handle }} 18 |
19 | ("{}", t!("notification_content.catalog, notification_content.message)); 20 |
21 | 22 |

23 |
24 |
25 |
26 |
27 | 28 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/notification_dropdown.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::elements::NotificationDropdown; 2 | @use rust_i18n::t; 3 | 4 | @(notifications: &NotificationDropdown) 5 | 6 | 7 | 42 | 43 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/elements/search_bar.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::elements::SearchBar; 2 | 3 | @(search_bar: &SearchBar) 4 | 5 | 13 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/error/error_http.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | !! ERHMAGERD !! 5 |

6 |

{{error_code}}

7 |
8 |

9 | Something has gone horribly wrong 10 |

11 |
12 | Error 13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/first_login.rs.html: -------------------------------------------------------------------------------- 1 | @use rust_i18n::t; 2 | 3 | @use crate::{FirstLogin, templates::{base, elements::{alert, input_text, input_select, input_checkbox}}}; 4 | 5 | @(first_login: &FirstLogin) 6 | 7 | @:base(first_login.catalog, "Aardwolf | Get Posting", { 8 |
9 |

@i18n!(first_login.catalog, "Get posting!")

10 |
11 | @i18n!(first_login.catalog, "Fill out your profile information") 12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | @if let Some(ref err) = first_login.alert { 20 | @:alert(err) 21 | } 22 | 23 | 24 | @:input_text(&first_login.display_name) 25 | @:input_text(&first_login.shortname) 26 | @:input_select(&first_login.follow_policy) 27 | @:input_select(&first_login.default_visibility) 28 | @:input_checkbox(&first_login.is_searchable) 29 | 30 |
31 |
32 |
33 |
34 | }); 35 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/footer.rs.html: -------------------------------------------------------------------------------- 1 | @use gettext::Catalog; 2 | @use rust_i18n::t; 3 | 4 | @use crate::templates::elements::icon; 5 | 6 | @(catalog: &Catalog) 7 | 8 | 21 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/home/feed.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::home::Feed; 2 | 3 | @(feed: &Feed) 4 | 5 |
6 |
7 |

8 | Profile picture 9 |

10 |
11 |
12 |
13 |

14 | John Doe 15 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis porta eros lacus, nec ultricies elit blandit non. Suspendisse pellentesque mauris sit amet dolor blandit rutrum. Nunc in tempus turpis. 16 |
17 | Like · Reply · Boost ·
· 3 hrs 18 |

19 |
20 | 21 |
22 |
23 |

24 | Profile picture 25 |

26 |
27 |
28 |
29 |

30 | Jane Doe 31 |
Donec sollicitudin urna eget eros malesuada sagittis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam blandit nisl a nulla sagittis, a lobortis leo feugiat. 32 |
33 | Like · Reply · Boost · 34 |

35 |
36 |
37 |
38 |
39 |
40 | 41 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/home/home.rs.html: -------------------------------------------------------------------------------- 1 | @use crate::{ 2 | home::Home, 3 | templates::{base, home::nav_top, home::new_post, home::feed, asides::shortcuts}, 4 | }; 5 | 6 | @(home_data: &Home) 7 | 8 | @:base(home_data.catalog, "Aardwolf | Home", { 9 | @:nav_top(&home_data.nav_top) 10 |
11 |
12 | @:shortcuts(&home_data.shortcuts) 13 |
14 |
15 |
16 | @:new_post(&home_data.new_post) 17 | @:feed(&home_data.feed) 18 |
19 |
20 |
21 | }) 22 | 23 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/home/nav_top.rs.html: -------------------------------------------------------------------------------- 1 | @use rust_i18n::t; 2 | @use crate::home::NavTop; 3 | 4 | @(nav_top_data: &NavTop) 5 | 6 | 35 | 36 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/html_head.rs.html: -------------------------------------------------------------------------------- 1 | @(title: &str) 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | @title 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/posts/new_post.rs.html: -------------------------------------------------------------------------------- 1 | @(new_post: &NewPost) 2 |
3 |
4 |

5 | @new_post.username 6 |

7 |
8 |
9 |
10 | @if let Some(ref alert) = new_post.alert { 11 | @:alert(alert) 12 | } 13 | 14 | 15 | 16 | @:input_textarea(&new_post.source); 17 | 18 | @:input_select(&new_post.visibility); 19 | 20 | @:input_text(&new_post.name); 21 | 22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/posts/reply_post.rs.html: -------------------------------------------------------------------------------- 1 | @(reply_post: &ReplyPost) 2 |
3 |
4 |

5 | @reply_post.username 6 |

7 |
8 |
9 | @if let Some(ref alert) = reply_post.alert { 10 |
@:alert(alert)
11 | } 12 | 13 | @:input_textarea(&reply_post.source) 14 | @:input_select(&reply_post.visibility) 15 | @:input_text(&reply_post.name) 16 | 17 |
18 |
19 | -------------------------------------------------------------------------------- /aardwolf-templates/templates/sign_up.rs.html: -------------------------------------------------------------------------------- 1 | @use rust_i18n::t; 2 | 3 | @use crate::{SignUp, templates::{base, elements::{alert, input_email, input_password}}}; 4 | 5 | @(sign_up: &SignUp) 6 | 7 | @:base(sign_up.catalog, "Aardwolf | Sign Up", { 8 |
9 |

@i18n!(sign_up.catalog, "Aardwolf Instance")

10 | 13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 |

21 | @i18n!(sign_up.catalog, "About Aardwolf") 22 |

23 |

24 | @i18n!(sign_up.catalog, "This is who we are!") 25 |

26 | @i18n!(sign_up.catalog, "really-long-platform-description") 27 |
28 |
29 |

30 | @i18n!(sign_up.catalog, "Create an Account") 31 |

32 |

33 | @i18n!(sign_up.catalog, "Feel free to sign up!") 34 |

35 |
36 | 37 | @if let Some(ref a) = sign_up.alert { 38 | @:alert(a) 39 | } 40 | 41 | @:input_email(&sign_up.email) 42 | @:input_password(&sign_up.password, &sign_up.catalog) 43 | @:input_password(&sign_up.password_confirmation, &sign_up.catalog) 44 | 45 |
46 |
47 |
48 |
49 |
50 | }) 51 | -------------------------------------------------------------------------------- /aardwolf-templates/translations/en/LC_MESSAGES/aardwolf.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aardwolf-Social/aardwolf-social/c6e7cf8c8b9d2a95b47fffe9729777bad6902d86/aardwolf-templates/translations/en/LC_MESSAGES/aardwolf.mo -------------------------------------------------------------------------------- /aardwolf-templates/translations/pl/LC_MESSAGES/aardwolf.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aardwolf-Social/aardwolf-social/c6e7cf8c8b9d2a95b47fffe9729777bad6902d86/aardwolf-templates/translations/pl/LC_MESSAGES/aardwolf.mo -------------------------------------------------------------------------------- /aardwolf-test-helpers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-test-helpers" 3 | version = "0.1.0" 4 | authors = ["asonix "] 5 | edition = "2021" 6 | 7 | [dependencies.aardwolf-models] 8 | version = "0.1" 9 | path = "../aardwolf-models" 10 | features = ["test"] 11 | -------------------------------------------------------------------------------- /aardwolf-test-helpers/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use aardwolf_models::test_helper as models; 2 | -------------------------------------------------------------------------------- /aardwolf-types/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-types" 3 | version = "0.1.0" 4 | authors = ["asonix "] 5 | edition = "2021" 6 | 7 | [features] 8 | default = ["with-actix"] 9 | with-actix = ["actix-web", "futures", "r2d2"] 10 | 11 | [dependencies] 12 | anyhow = "1.0" 13 | base64 = "0.22.1" 14 | csrf = "0.4.2" 15 | hmac = "0.12.1" 16 | sha2 = "0.10" 17 | rand = "0.9.0" 18 | derive_builder = "0.20.1" 19 | log = "0.4" 20 | openssl = "0.10" 21 | mime = "0.3" 22 | serde = "1.0" 23 | serde_derive = "1.0" 24 | thiserror = "2.0.11" 25 | url = "2.5" 26 | url_serde = "0.2" 27 | 28 | 29 | [dependencies.aardwolf-models] 30 | version = "0.1" 31 | path = "../aardwolf-models" 32 | 33 | [dependencies.actix-web] 34 | version = "4.9" 35 | optional = true 36 | 37 | [dependencies.diesel] 38 | version = "2.2" 39 | default-features = false 40 | features = ["postgres", "uuid", "chrono", "r2d2"] 41 | 42 | [dependencies.r2d2] 43 | version = "0.8" 44 | optional = true 45 | 46 | [dependencies.futures] 47 | version = "0.3" 48 | optional = true 49 | features = ["compat"] 50 | 51 | [dev-dependencies] 52 | aardwolf-test-helpers = { version = "0.1", path = "../aardwolf-test-helpers" } -------------------------------------------------------------------------------- /aardwolf-types/src/apps.rs: -------------------------------------------------------------------------------- 1 | use crate::scope::Scope; 2 | 3 | #[derive(Debug, Clone, PartialEq)] 4 | pub struct App { 5 | pub client_name: String, 6 | pub redirect_uris: String, 7 | pub scopes: Scope, 8 | pub website: Option, 9 | } 10 | 11 | #[derive(Default, Builder, Debug, Clone, PartialEq, Serialize)] 12 | #[builder(setter(into))] 13 | pub struct AppId { 14 | id: String, 15 | client_id: String, 16 | client_secret: String, 17 | } 18 | -------------------------------------------------------------------------------- /aardwolf-types/src/error.rs: -------------------------------------------------------------------------------- 1 | use serde::ser::Serialize; 2 | use std::error::Error; 3 | 4 | pub enum ResponseKind { 5 | BadRequest, 6 | RequiresAuthentication, 7 | RequiresPermission, 8 | NotFound, 9 | InternalServerError, 10 | } 11 | 12 | pub trait AardwolfFail: Serialize + Error {} 13 | 14 | #[derive(Clone, Debug)] 15 | pub struct RedirectTo(String); 16 | 17 | impl RedirectTo { 18 | pub fn new(s: String) -> Self { 19 | RedirectTo(s) 20 | } 21 | 22 | pub fn path(&self) -> &str { 23 | &self.0 24 | } 25 | } 26 | 27 | pub trait RedirectFail: AardwolfFail { 28 | fn redirect(&self) -> RedirectTo; 29 | } 30 | 31 | #[derive(Clone, Debug)] 32 | pub struct TemplateName(String); 33 | 34 | impl TemplateName { 35 | pub fn new(s: &str) -> Self { 36 | TemplateName(s.to_owned()) 37 | } 38 | 39 | pub fn name(&self) -> &str { 40 | &self.0 41 | } 42 | } 43 | 44 | pub trait TemplateFail: AardwolfFail { 45 | fn template(&self) -> TemplateName; 46 | 47 | fn response_kind(&self) -> ResponseKind; 48 | } 49 | -------------------------------------------------------------------------------- /aardwolf-types/src/forms.rs: -------------------------------------------------------------------------------- 1 | pub mod app; 2 | pub mod auth; 3 | pub mod personas; 4 | pub mod posts; 5 | -------------------------------------------------------------------------------- /aardwolf-types/src/forms/app.rs: -------------------------------------------------------------------------------- 1 | use crate::{apps::App, error::AardwolfFail, scope::Scope, traits::Validate}; 2 | use thiserror::Error; 3 | 4 | #[derive(Clone, Debug, Error, Serialize)] 5 | pub enum CreateAppError { 6 | #[error("validation error when creating app")] 7 | ValidationError, 8 | } 9 | 10 | impl AardwolfFail for CreateAppError {} 11 | 12 | /// Represents the form that is POSTed to /api/v1/apps to create an application 13 | #[derive(Deserialize)] 14 | pub struct CreateApp { 15 | client_name: String, 16 | redirect_uris: String, 17 | scopes: Scope, 18 | website: Option, 19 | } 20 | 21 | impl Validate for CreateApp { 22 | type Item = App; 23 | type Error = CreateAppError; 24 | 25 | fn validate(self) -> Result { 26 | if self.client_name.is_empty() || self.client_name.len() > 256 { 27 | return Err(CreateAppError::ValidationError); 28 | } 29 | 30 | if self.redirect_uris.is_empty() { 31 | return Err(CreateAppError::ValidationError); 32 | } 33 | 34 | let CreateApp { 35 | client_name, 36 | redirect_uris, 37 | scopes, 38 | website, 39 | } = self; 40 | 41 | Ok(App { 42 | client_name, 43 | redirect_uris, 44 | scopes, 45 | website, 46 | }) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /aardwolf-types/src/forms/auth/mod.rs: -------------------------------------------------------------------------------- 1 | mod signin_form; 2 | mod signup_form; 3 | 4 | pub use self::{ 5 | signin_form::{ 6 | SignInEmailValidationFail, SignInForm, SignInFormState, SignInPasswordValidationFail, 7 | ValidateSignInForm, ValidateSignInFormFail, ValidatedSignInForm, 8 | }, 9 | signup_form::{ 10 | SignUpEmailValidationFail, SignUpForm, SignUpFormState, 11 | SignUpPasswordConfirmationValidationFail, SignUpPasswordValidationFail, ValidateSignUpForm, 12 | ValidateSignUpFormFail, ValidatedSignUpForm, 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /aardwolf-types/src/forms/personas/creation_fail.rs: -------------------------------------------------------------------------------- 1 | use aardwolf_models::user::PermissionError; 2 | use diesel::result::Error as DieselError; 3 | use openssl::error::ErrorStack; 4 | use thiserror::Error; 5 | 6 | use crate::{error::AardwolfFail, forms::personas::ValidatePersonaCreationFail}; 7 | 8 | #[derive(Clone, Debug, Error, Serialize)] 9 | pub enum PersonaCreationFail { 10 | #[error("Failed to validate persona")] 11 | Validation(#[source] ValidatePersonaCreationFail), 12 | #[error("User doesn't have permission to create persona")] 13 | Permission, 14 | #[error("Error in database")] 15 | Database, 16 | #[error("Error generating keys")] 17 | Keygen, 18 | } 19 | 20 | impl AardwolfFail for PersonaCreationFail {} 21 | 22 | impl From for PersonaCreationFail { 23 | fn from(e: ValidatePersonaCreationFail) -> Self { 24 | PersonaCreationFail::Validation(e) 25 | } 26 | } 27 | 28 | impl From for PersonaCreationFail { 29 | fn from(_: DieselError) -> Self { 30 | PersonaCreationFail::Database 31 | } 32 | } 33 | 34 | impl From for PersonaCreationFail { 35 | fn from(e: PermissionError) -> Self { 36 | match e { 37 | PermissionError::Diesel => PersonaCreationFail::Database, 38 | PermissionError::Permission => PersonaCreationFail::Permission, 39 | } 40 | } 41 | } 42 | 43 | impl From for PersonaCreationFail { 44 | fn from(_: ErrorStack) -> Self { 45 | PersonaCreationFail::Keygen 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /aardwolf-types/src/forms/personas/mod.rs: -------------------------------------------------------------------------------- 1 | mod creation_fail; 2 | mod creation_form; 3 | 4 | pub use self::{ 5 | creation_fail::PersonaCreationFail, 6 | creation_form::{ 7 | PersonaCreationForm, PersonaCreationFormState, ValidateDefaultVisibilityFail, 8 | ValidateDisplayNameFail, ValidateFollowPolicyFail, ValidateIsSearchableFail, 9 | ValidatePersonaCreationFail, ValidatePersonaCreationForm, ValidateShortnameFail, 10 | ValidatedPersonaCreationForm, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /aardwolf-types/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate derive_builder; 3 | #[macro_use] 4 | extern crate log; 5 | #[macro_use] 6 | extern crate serde_derive; 7 | 8 | pub mod apps; 9 | pub mod csrf; 10 | pub mod error; 11 | pub mod forms; 12 | pub mod operations; 13 | pub mod scope; 14 | pub mod traits; 15 | -------------------------------------------------------------------------------- /aardwolf-types/src/operations.rs: -------------------------------------------------------------------------------- 1 | pub mod check_create_persona_permission; 2 | pub mod check_create_post_permission; 3 | pub mod check_delete_persona_permission; 4 | pub mod confirm_account; 5 | pub mod create_persona; 6 | pub mod create_post; 7 | pub mod delete_persona; 8 | pub mod fetch_authenticated_user; 9 | pub mod fetch_base_actor; 10 | pub mod fetch_persona; 11 | pub mod sign_in; 12 | pub mod sign_up; 13 | -------------------------------------------------------------------------------- /aardwolf-yew-frontend/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aardwolf-yew-frontend" 3 | version = "0.1.0" 4 | authors = ["Banjo Fox "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | yew = { version = "^0.21.0", features = ["csr"]} 11 | yew-router = "^0.18.0" 12 | wasm-bindgen = "0.2.93" # Easy support for interacting between JS and Rust. 13 | log = {version = "0.4.22", features = ["std", "serde"]} # Also used by main app for logging 14 | wasm-logger = "0.2.0" # Using this instead of Gloo because we already use log 15 | serde = "1.0.209" 16 | serde_json = "1.0.128" 17 | 18 | rust-i18n = "3.1.2" 19 | 20 | [dependencies.aardwolf-localization] 21 | version = "0.1" 22 | path = "../aardwolf-localization" 23 | -------------------------------------------------------------------------------- /aardwolf-yew-frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | " /> 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /aardwolf-yew-frontend/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Load I18n macro, for allow you use `t!` macro in anywhere. 2 | #[macro_use] 3 | extern crate rust_i18n; 4 | use serde::{Deserialize, Serialize}; 5 | use yew::prelude::*; 6 | 7 | // Pull in the template modules 8 | pub mod templates; 9 | 10 | // Start using the template 11 | use templates::elements::main_title::PageTitle; 12 | use templates::layout::footer::Footer; 13 | use templates::pages::sign_up::SignUp; 14 | 15 | // Lets make a struct for testing console logging 16 | #[derive(Serialize, Deserialize)] 17 | struct LogMe { 18 | username: String, 19 | favorite_pizza: String, 20 | } 21 | 22 | #[function_component(Aardwolf)] 23 | pub fn aardwolf() -> Html { 24 | // Demo for logging to the browsers console 25 | log::info!("Hello browser console! :D"); 26 | log::error!("Ohnoes! There was an OOPSIE!"); 27 | 28 | let test_debug = "THAT THING"; 29 | log::debug!("Hey dev, heres the {} you wanted!!", test_debug); 30 | 31 | // Give values to our LogMe struct 32 | let log_me = LogMe { 33 | username: "DemoUser".to_owned(), 34 | favorite_pizza: "Hawaiian".to_owned(), 35 | }; 36 | 37 | // Use j as a variable for our serde_json string? 38 | let j = serde_json::to_string_pretty(&log_me); 39 | 40 | // Finally pretty print our serde'd struct data x'D! 41 | log::info!("{:#?}", j); 42 | 43 | // Start of the html! Yew macro 44 | html! { 45 | <> 46 | 47 | 48 |