mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
118 lines
3.4 KiB
Rust
118 lines
3.4 KiB
Rust
mod app_state;
|
|
mod commands;
|
|
mod managed_agents;
|
|
mod models;
|
|
mod relay;
|
|
mod util;
|
|
|
|
use app_state::build_app_state;
|
|
use commands::*;
|
|
use tauri_plugin_window_state::StateFlags;
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.plugin(tauri_plugin_opener::init())
|
|
.plugin(
|
|
tauri_plugin_window_state::Builder::default()
|
|
.with_state_flags(StateFlags::all() & !StateFlags::VISIBLE)
|
|
.build(),
|
|
)
|
|
.plugin(tauri_plugin_websocket::init())
|
|
.plugin(tauri_plugin_dialog::init())
|
|
.manage(build_app_state())
|
|
.invoke_handler(tauri::generate_handler![
|
|
get_identity,
|
|
get_profile,
|
|
update_profile,
|
|
get_user_profile,
|
|
get_users_batch,
|
|
get_presence,
|
|
set_presence,
|
|
get_relay_ws_url,
|
|
discover_acp_providers,
|
|
discover_managed_agent_prereqs,
|
|
sign_event,
|
|
create_auth_event,
|
|
get_channels,
|
|
create_channel,
|
|
get_channel_details,
|
|
get_channel_members,
|
|
update_channel,
|
|
set_channel_topic,
|
|
set_channel_purpose,
|
|
archive_channel,
|
|
unarchive_channel,
|
|
delete_channel,
|
|
add_channel_members,
|
|
remove_channel_member,
|
|
join_channel,
|
|
leave_channel,
|
|
get_feed,
|
|
search_messages,
|
|
send_channel_message,
|
|
add_reaction,
|
|
remove_reaction,
|
|
get_event,
|
|
upload_media,
|
|
pick_and_upload_media,
|
|
upload_media_bytes,
|
|
list_tokens,
|
|
mint_token,
|
|
revoke_token,
|
|
revoke_all_tokens,
|
|
list_relay_agents,
|
|
list_managed_agents,
|
|
create_managed_agent,
|
|
start_managed_agent,
|
|
stop_managed_agent,
|
|
delete_managed_agent,
|
|
mint_managed_agent_token,
|
|
get_managed_agent_log,
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use serde_json::json;
|
|
|
|
use crate::{models::ChannelInfo, util::percent_encode};
|
|
|
|
#[test]
|
|
fn channel_info_defaults_is_member_for_legacy_payloads() {
|
|
let channel: ChannelInfo = serde_json::from_value(json!({
|
|
"id": "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50",
|
|
"name": "general",
|
|
"channel_type": "stream",
|
|
"visibility": "open",
|
|
"description": "General discussion",
|
|
"topic": null,
|
|
"purpose": null,
|
|
"member_count": 3,
|
|
"last_message_at": null,
|
|
"archived_at": null,
|
|
"participants": [],
|
|
"participant_pubkeys": []
|
|
}))
|
|
.expect("legacy payload should deserialize");
|
|
|
|
assert!(channel.is_member);
|
|
}
|
|
|
|
#[test]
|
|
fn percent_encode_leaves_unreserved_chars() {
|
|
assert_eq!(
|
|
percent_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"),
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn percent_encode_escapes_unicode_and_reserved_chars() {
|
|
assert_eq!(percent_encode("👍"), "%F0%9F%91%8D");
|
|
assert_eq!(percent_encode("a/b?c"), "a%2Fb%3Fc");
|
|
}
|
|
}
|