Skip to content

Commit

Permalink
feat: implement fep-2c59 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Feb 22, 2024
1 parent ac4c056 commit 137f685
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions FEDERATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md)
- [FEP-fffd: Proxy Objects](https://codeberg.org/fediverse/fep/src/branch/main/fep/fffd/fep-fffd.md)
- [FEP-4adb: Dereferencing identifiers with webfinger](https://codeberg.org/fediverse/fep/src/branch/main/fep/4adb/fep-4adb.md)
- [FEP-2c59: Discovery of a Webfinger address from an ActivityPub actor](https://codeberg.org/fediverse/fep/src/branch/main/fep/2c59/fep-2c59.md)

## ActivityPub

Expand Down
4 changes: 3 additions & 1 deletion crates/api_apub/src/users/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub async fn user(
// "@context": [
// "https://www.w3.org/ns/activitystreams",
// "https://w3id.org/security/v1",
// "https://purl.archive.org/socialweb/webfinger",
// {
// "xrd": "http://docs.oasis-open.org/ns/xri/xrd-1.0#",
// "aliases": {
Expand All @@ -65,8 +66,9 @@ pub async fn user(
let context = vec![
Value::String(context().to_string()),
Value::String(security().to_string()),
// FEP-2c59
Value::String(String::from("https://purl.archive.org/socialweb/webfinger")),
// FEP-4adb
// https://github.com/importantimport/hatsu/issues/15
json!({
"xrd": "http://docs.oasis-open.org/ns/xri/xrd-1.0#",
"aliases": {
Expand Down
6 changes: 4 additions & 2 deletions crates/apub/src/actors/db_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ impl Object for ApubUser {
followers: Url::parse(&self.followers)?,
following: Url::parse(&self.following)?,
// FEP-4adb
// https://github.com/importantimport/hatsu/issues/15
// TODO: customize via _hatsu.aliases
// TODO: customize via _hatsu.preferred_username
aliases: Some(vec![
format!(
"acct:{}@{}",
&self.preferred_username, &self.preferred_username
),
format!("acct:{}@{}", &self.preferred_username, data.domain()),
]),
// FEP-2c59
// TODO: customize via _hatsu.preferred_username
webfinger: Some(format!("acct:{}@{}", &self.preferred_username, &self.preferred_username)),
public_key: self.public_key(),
})
}
Expand Down
4 changes: 3 additions & 1 deletion crates/apub/src/actors/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ pub struct Service {
// 正在关注
pub following: Url,
/// FEP-4adb
/// https://github.com/importantimport/hatsu/issues/15
#[serde(skip_serializing_if = "Option::is_none")]
pub aliases: Option<Vec<String>>,
/// FEP-2c59
#[serde(skip_serializing_if = "Option::is_none")]
pub webfinger: Option<String>,
// 公钥
#[schema(value_type = PublicKeySchema)]
pub public_key: PublicKey,
Expand Down
1 change: 1 addition & 0 deletions docs/src/others/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md)
- [FEP-fffd: Proxy Objects](https://codeberg.org/fediverse/fep/src/branch/main/fep/fffd/fep-fffd.md)
- [FEP-4adb: Dereferencing identifiers with webfinger](https://codeberg.org/fediverse/fep/src/branch/main/fep/4adb/fep-4adb.md)
- [FEP-2c59: Discovery of a Webfinger address from an ActivityPub actor](https://codeberg.org/fediverse/fep/src/branch/main/fep/2c59/fep-2c59.md)

## ActivityPub

Expand Down

0 comments on commit 137f685

Please sign in to comment.