aboutsummaryrefslogtreecommitdiff
path: root/base/src/federation.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-30 10:47:54 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-30 10:47:54 +0200
commita2ef3f6ec4c830611fde1a2e935588ccbbc61c03 (patch)
treeddcc1cb501e6c7237edd491aa7136d02150d03d3 /base/src/federation.rs
parent212a0f23bc894faf88e159560c113f504349cc05 (diff)
downloadjellything-a2ef3f6ec4c830611fde1a2e935588ccbbc61c03.tar
jellything-a2ef3f6ec4c830611fde1a2e935588ccbbc61c03.tar.bz2
jellything-a2ef3f6ec4c830611fde1a2e935588ccbbc61c03.tar.zst
config works
Diffstat (limited to 'base/src/federation.rs')
-rw-r--r--base/src/federation.rs108
1 files changed, 54 insertions, 54 deletions
diff --git a/base/src/federation.rs b/base/src/federation.rs
index 879ce96..b24d113 100644
--- a/base/src/federation.rs
+++ b/base/src/federation.rs
@@ -3,62 +3,62 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use crate::SECRETS;
-use anyhow::anyhow;
-use jellyclient::{Instance, Session};
-use jellycommon::{config::FederationAccount, user::CreateSessionParams};
-use std::{collections::HashMap, sync::Arc};
-use tokio::sync::RwLock;
-pub struct Federation {
- instances: HashMap<String, Instance>,
- sessions: RwLock<HashMap<String, Arc<Session>>>,
-}
+// use anyhow::anyhow;
+// use jellyclient::{Instance, Session};
+// use jellycommon::{config::FederationAccount, user::CreateSessionParams};
+// use std::{collections::HashMap, sync::Arc};
+// use tokio::sync::RwLock;
-impl Federation {
- pub fn initialize() -> Self {
- let instances = SECRETS
- .federation
- .iter()
- .map(|(k, FederationAccount { tls, .. })| {
- (k.to_owned(), Instance::new(k.to_owned(), *tls))
- })
- .collect::<HashMap<_, _>>();
+// pub struct Federation {
+// instances: HashMap<String, Instance>,
+// sessions: RwLock<HashMap<String, Arc<Session>>>,
+// }
- Self {
- instances,
- sessions: Default::default(),
- }
- }
+// impl Federation {
+// pub fn initialize() -> Self {
+// let instances = SECRETS
+// .federation
+// .iter()
+// .map(|(k, FederationAccount { tls, .. })| {
+// (k.to_owned(), Instance::new(k.to_owned(), *tls))
+// })
+// .collect::<HashMap<_, _>>();
- pub fn get_instance(&self, host: &String) -> anyhow::Result<&Instance> {
- self.instances.get(host).ok_or(anyhow!("unknown instance"))
- }
+// Self {
+// instances,
+// sessions: Default::default(),
+// }
+// }
- pub async fn get_session(&self, host: &String) -> anyhow::Result<Arc<Session>> {
- let mut w = self.sessions.write().await;
- if let Some(s) = w.get(host) {
- Ok(s.to_owned())
- } else {
- let FederationAccount {
- username, password, ..
- } = SECRETS
- .federation
- .get(host)
- .ok_or(anyhow!("no credentials of the remote server"))?;
- let s = Arc::new(
- self.get_instance(host)?
- .to_owned()
- .login(CreateSessionParams {
- username: username.to_owned(),
- password: password.to_owned(),
- expire: None,
- drop_permissions: None,
- })
- .await?,
- );
- w.insert(host.to_owned(), s.clone());
- Ok(s)
- }
- }
-}
+// pub fn get_instance(&self, host: &String) -> anyhow::Result<&Instance> {
+// self.instances.get(host).ok_or(anyhow!("unknown instance"))
+// }
+
+// pub async fn get_session(&self, host: &String) -> anyhow::Result<Arc<Session>> {
+// let mut w = self.sessions.write().await;
+// if let Some(s) = w.get(host) {
+// Ok(s.to_owned())
+// } else {
+// let FederationAccount {
+// username, password, ..
+// } = SECRETS
+// .federation
+// .get(host)
+// .ok_or(anyhow!("no credentials of the remote server"))?;
+// let s = Arc::new(
+// self.get_instance(host)?
+// .to_owned()
+// .login(CreateSessionParams {
+// username: username.to_owned(),
+// password: password.to_owned(),
+// expire: None,
+// drop_permissions: None,
+// })
+// .await?,
+// );
+// w.insert(host.to_owned(), s.clone());
+// Ok(s)
+// }
+// }
+// }