summaryrefslogtreecommitdiffstats
path: root/server/src/routes/federation.rs
diff options
context:
space:
mode:
authorFelix <me@nutomic.com>2020-01-14 16:26:19 +0100
committerFelix <me@nutomic.com>2020-01-14 16:30:54 +0100
commiteaf548b5db326addee318bcc2c7c742e4b79b6fa (patch)
treefebdc483976b5e3d38db4c68cfadd57ce89b3f61 /server/src/routes/federation.rs
parent35489a706bdd48bdb840a4ac13986214c456d6c9 (diff)
parentb300db475cbca846aea89800ecaa8661c59fd70b (diff)
Merge branch 'master' into federation
Diffstat (limited to 'server/src/routes/federation.rs')
-rw-r--r--server/src/routes/federation.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/server/src/routes/federation.rs b/server/src/routes/federation.rs
index 019a9a71..9667694a 100644
--- a/server/src/routes/federation.rs
+++ b/server/src/routes/federation.rs
@@ -5,6 +5,8 @@ use crate::apub;
use crate::settings::Settings;
use actix_web::web::Query;
use actix_web::{web, HttpResponse};
+use diesel::r2d2::{ConnectionManager, Pool};
+use diesel::PgConnection;
pub fn config(cfg: &mut web::ServiceConfig) {
if Settings::get().federation_enabled {
@@ -25,14 +27,16 @@ pub fn config(cfg: &mut web::ServiceConfig) {
// TODO: this is a very quick and dirty implementation for http api calls
.route(
"/api/v1/communities/list",
- web::get().to(|query: Query<ListCommunities>| {
- let res = Oper::new(UserOperation::ListCommunities, query.into_inner())
- .perform()
- .unwrap();
- HttpResponse::Ok()
- .content_type("application/json")
- .body(serde_json::to_string(&res).unwrap())
- }),
+ web::get().to(
+ |query: Query<ListCommunities>, db: web::Data<Pool<ConnectionManager<PgConnection>>>| {
+ let res = Oper::new(UserOperation::ListCommunities, query.into_inner())
+ .perform(&db.get().unwrap())
+ .unwrap();
+ HttpResponse::Ok()
+ .content_type("application/json")
+ .body(serde_json::to_string(&res).unwrap())
+ },
+ ),
);
}
}