honcho: plugin web pages with i18n, defer plugin detail to custom admin page
Nightly Build / build (push) Failing after 6m13s
Nightly Build / build (push) Failing after 6m13s
This commit is contained in:
@@ -66,6 +66,10 @@ pub struct PluginPageInfo {
|
||||
pub icon: String,
|
||||
pub priority: i32,
|
||||
pub entry_url: String,
|
||||
/// Mirrors [`core_api::plugin::PluginPage::admin_only`]. Lets the admin
|
||||
/// Plugins UI recognise a plugin's own config page and defer to it (hide the
|
||||
/// generic `config_schema` form, link out instead).
|
||||
pub admin_only: bool,
|
||||
/// Fragment-contract version the host speaks. Always 1 for now — bump when
|
||||
/// the contract changes so old hosts can refuse new fragments cleanly.
|
||||
pub api_version: u32,
|
||||
@@ -493,6 +497,7 @@ impl PluginManager {
|
||||
icon: page.icon.to_string(),
|
||||
priority: page.priority,
|
||||
entry_url: format!("/api/plugin/{}/{}", plugin.id(), page.entry),
|
||||
admin_only: page.admin_only,
|
||||
api_version: 1,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,6 +186,18 @@ impl UserChannelApi for Skald {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn is_admin(&self, user_id: &str) -> bool {
|
||||
// Built-in admin role; an unknown user or a lookup error fails closed.
|
||||
sqlx::query_as::<_, (String,)>("SELECT role_id FROM users WHERE id = ?")
|
||||
.bind(user_id)
|
||||
.fetch_optional(self.db().as_ref())
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|(r,)| r == crate::db::roles::ADMIN_ROLE_ID)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
async fn user_for_session(&self, token: &str) -> Option<String> {
|
||||
self.sessions().user_of(token)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user