mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 19:31:05 +00:00
Some federation improvements
This commit is contained in:
parent
f9443dfbd3
commit
b854d8f3a0
4 changed files with 28 additions and 41 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,5 +3,6 @@ ansible/inventory_dev
|
||||||
ansible/passwords/
|
ansible/passwords/
|
||||||
docker/lemmy_mine.hjson
|
docker/lemmy_mine.hjson
|
||||||
docker/dev/env_deploy.sh
|
docker/dev/env_deploy.sh
|
||||||
|
docker/federation-test/volumes
|
||||||
build/
|
build/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
40
docker/federation-test/docker-compose.yml
vendored
40
docker/federation-test/docker-compose.yml
vendored
|
@ -7,7 +7,7 @@ services:
|
||||||
- "127.0.0.1:8540:8540"
|
- "127.0.0.1:8540:8540"
|
||||||
environment:
|
environment:
|
||||||
- LEMMY_HOSTNAME=localhost:8540
|
- LEMMY_HOSTNAME=localhost:8540
|
||||||
- LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db_alpha:5432/lemmy
|
- LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_alpha:5432/lemmy
|
||||||
- LEMMY_JWT_SECRET=changeme
|
- LEMMY_JWT_SECRET=changeme
|
||||||
- LEMMY_FRONT_END_DIR=/app/dist
|
- LEMMY_FRONT_END_DIR=/app/dist
|
||||||
- LEMMY_FEDERATION_ENABLED=true
|
- LEMMY_FEDERATION_ENABLED=true
|
||||||
|
@ -16,23 +16,16 @@ services:
|
||||||
- RUST_BACKTRACE=1
|
- RUST_BACKTRACE=1
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- lemmy_db_alpha
|
- postgres_alpha
|
||||||
lemmy_db_alpha:
|
postgres_alpha:
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=lemmy
|
- POSTGRES_USER=lemmy
|
||||||
- POSTGRES_PASSWORD=${LEMMY_DATABASE_PASSWORD}
|
- POSTGRES_PASSWORD=password
|
||||||
- POSTGRES_DB=lemmy
|
- POSTGRES_DB=lemmy
|
||||||
volumes:
|
volumes:
|
||||||
- lemmy_db_alpha:/var/lib/postgresql/data
|
- ./volumes/postgres_alpha:/var/lib/postgresql/data
|
||||||
restart: always
|
restart: always
|
||||||
# lemmy_pictshare_alpha:
|
|
||||||
# image: shtripok/pictshare:latest
|
|
||||||
# ports:
|
|
||||||
# - "127.0.0.1:8550:80"
|
|
||||||
# volumes:
|
|
||||||
# - lemmy_pictshare_alpha:/usr/share/nginx/html/data
|
|
||||||
# restart: always
|
|
||||||
|
|
||||||
lemmy_beta:
|
lemmy_beta:
|
||||||
image: lemmy-federation-test:latest
|
image: lemmy-federation-test:latest
|
||||||
|
@ -40,7 +33,7 @@ services:
|
||||||
- "127.0.0.1:8541:8541"
|
- "127.0.0.1:8541:8541"
|
||||||
environment:
|
environment:
|
||||||
- LEMMY_HOSTNAME=localhost:8541
|
- LEMMY_HOSTNAME=localhost:8541
|
||||||
- LEMMY_DATABASE_URL=postgres://lemmy:password@lemmy_db_beta:5432/lemmy
|
- LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_beta:5432/lemmy
|
||||||
- LEMMY_JWT_SECRET=changeme
|
- LEMMY_JWT_SECRET=changeme
|
||||||
- LEMMY_FRONT_END_DIR=/app/dist
|
- LEMMY_FRONT_END_DIR=/app/dist
|
||||||
- LEMMY_FEDERATION_ENABLED=true
|
- LEMMY_FEDERATION_ENABLED=true
|
||||||
|
@ -49,26 +42,13 @@ services:
|
||||||
- RUST_BACKTRACE=1
|
- RUST_BACKTRACE=1
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- lemmy_db_beta
|
- postgres_beta
|
||||||
lemmy_db_beta:
|
postgres_beta:
|
||||||
image: postgres:12-alpine
|
image: postgres:12-alpine
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=lemmy
|
- POSTGRES_USER=lemmy
|
||||||
- POSTGRES_PASSWORD=${LEMMY_DATABASE_PASSWORD}
|
- POSTGRES_PASSWORD=password
|
||||||
- POSTGRES_DB=lemmy
|
- POSTGRES_DB=lemmy
|
||||||
volumes:
|
volumes:
|
||||||
- lemmy_db_beta:/var/lib/postgresql/data
|
- ./volumes/postgres_beta:/var/lib/postgresql/data
|
||||||
restart: always
|
restart: always
|
||||||
# lemmy_pictshare_beta:
|
|
||||||
# image: shtripok/pictshare:latest
|
|
||||||
# ports:
|
|
||||||
# - "127.0.0.1:8551:80"
|
|
||||||
# volumes:
|
|
||||||
# - lemmy_pictshare_beta:/usr/share/nginx/html/data
|
|
||||||
# restart: always
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
lemmy_db_alpha:
|
|
||||||
# lemmy_pictshare_alpha:
|
|
||||||
lemmy_db_beta:
|
|
||||||
# lemmy_pictshare_beta:
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use actix_web::body::Body;
|
||||||
use actix_web::web::Path;
|
use actix_web::web::Path;
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
impl Community {
|
impl Community {
|
||||||
pub fn as_group(&self) -> Group {
|
pub fn as_group(&self) -> Group {
|
||||||
|
@ -15,16 +16,18 @@ impl Community {
|
||||||
|
|
||||||
let mut group = Group::default();
|
let mut group = Group::default();
|
||||||
|
|
||||||
|
// TODO: why the hell is this code so awkward?
|
||||||
group.object_props.set_context_object(context()).ok();
|
group.object_props.set_context_object(context()).ok();
|
||||||
group.object_props.set_id_string(base_url.to_string()).ok();
|
group.object_props.set_id_string(self.id.to_string()).ok();
|
||||||
group
|
group
|
||||||
.object_props
|
.object_props
|
||||||
.set_name_string(self.name.to_owned())
|
.set_name_string(self.title.to_owned())
|
||||||
.ok();
|
.ok();
|
||||||
group
|
group
|
||||||
.object_props
|
.object_props
|
||||||
.set_published_utctime(to_datetime_utc(self.published))
|
.set_published_utctime(to_datetime_utc(self.published))
|
||||||
.ok();
|
.ok();
|
||||||
|
group.object_props.attributed_to = Some(json!(self.creator_id.to_string()));
|
||||||
if let Some(updated) = self.updated {
|
if let Some(updated) = self.updated {
|
||||||
group
|
group
|
||||||
.object_props
|
.object_props
|
||||||
|
@ -34,9 +37,7 @@ impl Community {
|
||||||
|
|
||||||
if let Some(description) = &self.description {
|
if let Some(description) = &self.description {
|
||||||
group
|
group
|
||||||
.object_props
|
.object_props.summary = Some(json!(description.to_string()));
|
||||||
.set_summary_string(description.to_string())
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group
|
group
|
||||||
|
@ -66,6 +67,7 @@ impl Community {
|
||||||
//As we are an object, we validated that the community id was valid
|
//As we are an object, we validated that the community id was valid
|
||||||
let community_followers = CommunityFollowerView::for_community(&connection, self.id).unwrap();
|
let community_followers = CommunityFollowerView::for_community(&connection, self.id).unwrap();
|
||||||
|
|
||||||
|
// TODO: we definitely dont want to make our follower list public, we should only expose the count
|
||||||
let ap_followers = community_followers
|
let ap_followers = community_followers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|follower| make_apub_endpoint("u", &follower.user_name))
|
.map(|follower| make_apub_endpoint("u", &follower.user_name))
|
||||||
|
|
|
@ -38,6 +38,7 @@ pub fn get_remote_community(identifier: String) -> Result<GetCommunityResponse,
|
||||||
let instance = x[1];
|
let instance = x[1];
|
||||||
let community_uri = format!("http://{}/federation/c/{}", instance, name);
|
let community_uri = format!("http://{}/federation/c/{}", instance, name);
|
||||||
let community: Group = reqwest::get(&community_uri)?.json()?;
|
let community: Group = reqwest::get(&community_uri)?.json()?;
|
||||||
|
dbg!(&community);
|
||||||
|
|
||||||
// TODO: looks like a bunch of data is missing from the activitypub response
|
// TODO: looks like a bunch of data is missing from the activitypub response
|
||||||
// TODO: i dont think simple numeric ids are going to work, we probably need something like uuids
|
// TODO: i dont think simple numeric ids are going to work, we probably need something like uuids
|
||||||
|
@ -46,14 +47,17 @@ pub fn get_remote_community(identifier: String) -> Result<GetCommunityResponse,
|
||||||
moderators: vec![],
|
moderators: vec![],
|
||||||
admins: vec![],
|
admins: vec![],
|
||||||
community: CommunityView {
|
community: CommunityView {
|
||||||
id: -1,
|
// TODO: why does the stupid library have everything stored as value without working autocomplete for methods???
|
||||||
name: identifier.clone(),
|
// i want to pull that whole lib in here and treat it as part of lemmy so we can fix this shit
|
||||||
title: identifier,
|
// TODO: we need to merge id and name into a single thing (stuff like @user@instance.com)
|
||||||
description: community.object_props.summary.map(|c| c.to_string()),
|
id: community.object_props.id.unwrap().as_str().unwrap().parse::<i32>().unwrap(),
|
||||||
|
name: name,
|
||||||
|
title: community.object_props.name.unwrap().as_str().unwrap().to_string(), // TODO: why does it still show !main@lemmy_beta:8541
|
||||||
|
description: community.object_props.summary.map(|c| c.to_string()), // TODO: this has an extra quote somehow
|
||||||
category_id: -1,
|
category_id: -1,
|
||||||
creator_id: -1,
|
creator_id: community.object_props.attributed_to.unwrap().as_str().unwrap().parse::<i32>().unwrap(),
|
||||||
removed: false,
|
removed: false,
|
||||||
published: naive_now(), // TODO: community.object_props.published
|
published: naive_now(), // TODO: need to handle time conversion (or handle it in apub lib)
|
||||||
updated: Some(naive_now()), // TODO: community.object_props.updated
|
updated: Some(naive_now()), // TODO: community.object_props.updated
|
||||||
deleted: false,
|
deleted: false,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
|
|
Loading…
Reference in a new issue