1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add federation webpage to society; fix dead link on home page

This commit is contained in:
NG (Graham)
2026-07-18 00:32:28 -04:00
parent 147a07c338
commit d9787734dc
11 changed files with 199 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ mod inventory;
pub use inventory::{UnlockedParts, UnlockOverride};
mod traits;
pub use traits::{UserProvider, User, UserToken, UserSlots, UserSlotData, VehicleData, UserAuthInfo, FederatedAuthInfo, UserLoginInfo, UserAuthenticator, FederatedAuthenticator, NewSlotData, UserId, RegistrationInfo, VehicleUploadData, ChatUser, AvatarInfo, GetAvatarInfo, ControlData, ControlType, CustomisationData, GetCustomisationData, SetSanction, SanctionType, LobbyUser, GameDescriptor, PlayerLobbyDescriptor, MultiplayerUser, PlayerScore, MultiplayerError, MultiplayerErrorCode, PlayerDescriptor, GameEventSetter, CurrentGameEvent, AuthError, IntercomUser, FakePlayers, ResolvedVehicle, CommonUser, IntercomListener, UserRole, SocialUser, SocialUserC, CurrencyType, CurrencyOp, MatchRewards, SingleplayerUser, PurchaseResult, FactoryUser, FriendInviteReturn, FriendData, FriendInviteStatus, SocialInfo, ClanData, ClanMember, ClanMemberRank, ClanType, ClanSearchQuery, ClanInviteData, Userless, GameOverrides, WebUser, GarageWebInfo, GarageWebStats, SanctionWebStats, AccountWebStats, SocialWebStats};
pub use traits::{UserProvider, User, UserToken, UserSlots, UserSlotData, VehicleData, UserAuthInfo, FederatedAuthInfo, UserLoginInfo, UserAuthenticator, FederatedAuthenticator, NewSlotData, UserId, RegistrationInfo, VehicleUploadData, ChatUser, AvatarInfo, GetAvatarInfo, ControlData, ControlType, CustomisationData, GetCustomisationData, SetSanction, SanctionType, LobbyUser, GameDescriptor, PlayerLobbyDescriptor, MultiplayerUser, PlayerScore, MultiplayerError, MultiplayerErrorCode, PlayerDescriptor, GameEventSetter, CurrentGameEvent, AuthError, IntercomUser, FakePlayers, ResolvedVehicle, CommonUser, IntercomListener, UserRole, SocialUser, SocialUserC, CurrencyType, CurrencyOp, MatchRewards, SingleplayerUser, PurchaseResult, FactoryUser, FriendInviteReturn, FriendData, FriendInviteStatus, SocialInfo, ClanData, ClanMember, ClanMemberRank, ClanType, ClanSearchQuery, ClanInviteData, Userless, GameOverrides, WebUser, GarageWebInfo, GarageWebStats, SanctionWebStats, AccountWebStats, SocialWebStats, FederationWebData, FederationWebDetails};
pub mod intercom;
pub use intercom::generate_token as generate_intercom_token;

View File

@@ -703,6 +703,7 @@ pub trait WebUser: CommonUser {
async fn account_stats(&self) -> Result<AccountWebStats, Box<dyn std::error::Error>>;
async fn sanction_stats(&self) -> Result<SanctionWebStats, Box<dyn std::error::Error>>;
async fn social_stats(&self) -> Result<SocialWebStats, Box<dyn std::error::Error>>;
async fn fedi_info(&self) -> Result<FederationWebData, Box<dyn std::error::Error>>;
}
pub struct GarageWebInfo {
@@ -749,6 +750,19 @@ pub struct SocialWebStats {
pub chats: Vec<String>,
}
pub struct FederationWebData {
pub federations: Vec<FederationWebDetails>,
}
pub struct FederationWebDetails {
pub id: i32,
pub domain: String,
pub auth: String,
pub society: String,
pub last_used: i64,
pub first_used: i64,
}
#[async_trait::async_trait]
pub trait Userless: Send + Sync {
async fn lobby_state_listener(&self) -> Result<super::IntercomListener<super::intercom::IntercomLobbyStateMessage>, reqwest_websocket::Error>;

View File

@@ -202,4 +202,20 @@ impl super::WebUser for super::account_json::UserData {
chats: chat_list,
})
}
async fn fedi_info(&self) -> Result<super::FederationWebData, Box<dyn std::error::Error>> {
let servers = self.db.federations_all().await?;
Ok(super::FederationWebData {
federations: servers.into_iter()
.map(|server| super::FederationWebDetails {
id: server.id,
domain: server.domain,
auth: server.auth,
society: server.society,
last_used: server.last_used_time,
first_used: server.creation_time,
})
.collect()
})
}
}