Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: importantimport/hatsu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0-beta.7
Choose a base ref
...
head repository: importantimport/hatsu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.2.0-beta.8
Choose a head ref
  • 8 commits
  • 12 files changed
  • 1 contributor

Commits on May 22, 2024

  1. chore: update deps

    kwaa committed May 22, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    8bcaeb0 View commit details
  2. chore: update direct deps

    kwaa committed May 22, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    b454d37 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    b724d74 View commit details
  4. fix: impl into subsystem

    kwaa committed May 22, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    6abdb27 View commit details

Commits on May 24, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    bb18659 View commit details
  2. docs(users/backfeed): add kkna

    kwaa committed May 24, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    b5636c6 View commit details
  3. docs: update kkna

    kwaa committed May 24, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    b176682 View commit details
  4. chore: release v0.2.0-beta.8

    kwaa committed May 24, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    kwaa 藍+85CD
    Copy the full SHA
    28dadc6 View commit details
711 changes: 367 additions & 344 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.2.0-beta.7"
version = "0.2.0-beta.8"
authors = ["藍+85CD"]
edition = "2021"
rust-version = "1.75"
@@ -84,9 +84,10 @@ chrono = "0.4"
enum_delegate = "0.2"
feed-rs = "1.3"
futures = "0.3"
markdown = "1.0.0-alpha.13"
markdown = "1.0.0-alpha"
# https://github.com/LemmyNet/activitypub-federation-rust/blob/16844f048afeeeb5d7d0df3a559505cbcd684a61/Cargo.toml#L40
reqwest = { version = "0.11", features = ["json"] }
scraper = "0.17"
scraper = "0.19"
sea-orm = { version = "0.12", features = [
"sqlx-postgres",
"sqlx-sqlite",
@@ -99,15 +100,15 @@ sea-orm = { version = "0.12", features = [
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] }
tokio-cron-scheduler = "*"
tokio-graceful-shutdown = "0.13"
tokio-cron-scheduler = "0.10"
tokio-graceful-shutdown = "0.15"
tower-http = { version = "0.4", features = ["cors", "trace"] }
tracing = { version = "0.1" }
tracing-error = "0.2"
url = { version = "2.4", features = ["serde"] }
urlencoding = "2"
utoipa = { version = "4", features = ["axum_extras", "url", "uuid"] }
uuid = { version = "1.4", features = [
uuid = { version = "1.8", features = [
"v4",
"v7",
"fast-rng",
@@ -128,9 +129,6 @@ activitypub_federation = { workspace = true }
dotenvy = "0.15"
sea-orm = { workspace = true }
snmalloc-rs = "0.3"
# https://github.com/launchbadge/sqlx/issues/3189
# https://github.com/launchbadge/sqlx/pull/3190
time = "=0.3.34"
tokio = { workspace = true }
tokio-graceful-shutdown = { workspace = true }
tracing = { workspace = true }
1 change: 1 addition & 0 deletions crates/backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ hatsu_openapi = { workspace = true }
hatsu_well_known = { workspace = true }
hatsu_utils = { workspace = true }
activitypub_federation = { workspace = true }
async-trait = { workspace = true }
axum = { workspace = true }
tokio-graceful-shutdown = { workspace = true }
tower-http = { workspace = true }
7 changes: 5 additions & 2 deletions crates/backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use std::net::SocketAddr;

use activitypub_federation::config::{FederationConfig, FederationMiddleware};
use hatsu_utils::{AppData, AppError};
use tokio_graceful_shutdown::SubsystemHandle;
use tokio_graceful_shutdown::{IntoSubsystem, SubsystemHandle};
use tower_http::{cors::CorsLayer, trace::TraceLayer};

mod favicon;
@@ -19,8 +19,11 @@ impl Server {
federation_config: federation_config.clone(),
}
}
}

pub async fn run(self, subsys: SubsystemHandle<AppError>) -> Result<(), AppError> {
#[async_trait::async_trait]
impl IntoSubsystem<AppError, AppError> for Server {
async fn run(self, subsys: SubsystemHandle<AppError>) -> Result<(), AppError> {
let data = self.federation_config.to_request_data();

// build our application with a route
1 change: 1 addition & 0 deletions crates/scheduler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ hatsu_db_schema = { workspace = true }
hatsu_feed = { workspace = true }
hatsu_utils = { workspace = true }
activitypub_federation = { workspace = true }
async-trait = { workspace = true }
sea-orm = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
7 changes: 5 additions & 2 deletions crates/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use activitypub_federation::config::FederationConfig;
use hatsu_utils::{AppData, AppError};
use tokio_cron_scheduler::{Job, JobScheduler};
use tokio_graceful_shutdown::SubsystemHandle;
use tokio_graceful_shutdown::{IntoSubsystem, SubsystemHandle};

mod update;

@@ -16,8 +16,11 @@ impl Scheduler {
federation_config: federation_config.clone(),
}
}
}

pub async fn run(self, _subsys: SubsystemHandle<AppError>) -> Result<(), AppError> {
#[async_trait::async_trait]
impl IntoSubsystem<AppError, AppError> for Scheduler {
async fn run(self, _subsys: SubsystemHandle<AppError>) -> Result<(), AppError> {
tracing::info!("creating scheduler");
let scheduler: JobScheduler = JobScheduler::new().await?;

3 changes: 2 additions & 1 deletion crates/utils/src/markdown.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
#[must_use]
pub fn markdown_to_html(value: &str) -> String {
match markdown::to_html_with_options(value, &markdown::Options::gfm()) {
Ok(result) | Err(result) => result,
Ok(result) => result,
Err(result) => result.to_string(),
}
}
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
- [with Aoba (Lume & Hono)](./users/redirecting-with-aoba.md)
- [with FEP-612d](./users/redirecting-with-fep-612d.md)
- [Backfeed](./users/backfeed.md)
- [based on KKna](./users/backfeed-based-on-kkna.md)
- [based on Mastodon Comments](./users/backfeed-based-on-mastodon-comments.md)
- [based on Webmention (TODO)](./users/backfeed-based-on-webmention.md)

22 changes: 22 additions & 0 deletions docs/src/users/backfeed-based-on-kkna.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Backfeed based on KKna

Written by the same authors as Hatsu, KKna provides the simplest integration for Hatsu.

## Examples

> Replace `hatsu.local` with your Hatsu instance.
```html
<script type="module">
import { defineConfig } from 'https://esm.sh/@kkna/context'
import { hatsu } from 'https://esm.sh/@kkna/preset-hatsu'
defineConfig({
presets: [hatsu({ instance: 'https://hatsu.local' })],
})
</script>
<script type="module" src="https://esm.sh/@kkna/component-material"></script>
<kkna-material></kkna-material>
```

You can use it with other presets or write your own components, see the [KKna Documentation](https://kkna.js.org/) for details.
2 changes: 2 additions & 0 deletions docs/src/users/backfeed.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

Display mentions received by Hatsu on your site.

## [based on KKna](./backfeed-based-on-kkna.md)

## [based on Mastodon Comments](./backfeed-based-on-mastodon-comments.md)

## [based on Webmention (TODO)](./backfeed-based-on-webmention.md)
2 changes: 2 additions & 0 deletions docs/src/users/feed.md
Original file line number Diff line number Diff line change
@@ -61,4 +61,6 @@ you might also want to check out the [Hatsu JSON Feed Extension](../others/json-

Hatsu uses `feed-rs` to parse XML feeds and convert them manually.

Please make sure your feed is valid in [W3C Feed Validation Service](https://validator.w3.org/feed/) first.

This section is currently lacking testing, so feel free to report bugs.
21 changes: 12 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use hatsu_utils::{AppData, AppEnv, AppError};
use human_panic::{metadata, setup_panic};
use sea_orm::{ActiveModelTrait, Database, EntityTrait, IntoActiveModel};
use tokio::time::Duration;
use tokio_graceful_shutdown::Toplevel;
use tokio_graceful_shutdown::{IntoSubsystem, SubsystemBuilder, Toplevel};
use tracing_subscriber::prelude::*;

#[tokio::main]
@@ -84,12 +84,15 @@ async fn main() -> Result<(), AppError> {
let scheduler = hatsu_scheduler::Scheduler::new(&federation_config);
let server = hatsu_backend::Server::new(&federation_config);

let _result = Toplevel::<AppError>::new()
.start("Scheduler", move |s| scheduler.run(s))
.start("Server", move |s| server.run(s))
.catch_signals()
.handle_shutdown_requests(Duration::from_millis(5000))
.await;

Ok(())
Toplevel::<AppError>::new(|s| async move {
s.start(SubsystemBuilder::new(
"Scheduler",
scheduler.into_subsystem(),
));
s.start(SubsystemBuilder::new("Server", server.into_subsystem()));
})
.catch_signals()
.handle_shutdown_requests(Duration::from_millis(1000))
.await
.map_err(|err| err.into())
}