pub struct OpenedStore { /* private fields */ }Expand description
A sealed messenger core opened for one session, plus the homeserver it performs released requests against. The Olm account was loaded or created into it. Private key material stays here. The device bearer stays in memory and is zeroed when this value is dropped.
Implementations§
Source§impl OpenedStore
impl OpenedStore
Sourcepub fn run_command(&mut self, req: &CmdRequest, now_ms: i64) -> CmdReply
pub fn run_command(&mut self, req: &CmdRequest, now_ms: i64) -> CmdReply
Runs one rich command for this session.
Source§impl OpenedStore
impl OpenedStore
Sourcepub fn open(
dir: &Path,
session_id: &str,
device_id: DeviceId,
user_id: &str,
server_name: &str,
backend: Arc<dyn Backend>,
device_token: &str,
) -> Result<Self, ShellError>
pub fn open( dir: &Path, session_id: &str, device_id: DeviceId, user_id: &str, server_name: &str, backend: Arc<dyn Backend>, device_token: &str, ) -> Result<Self, ShellError>
Derives the seal key from session_id, reads dir, and opens the
core. A different session id cannot open records this session sealed.
The host keychain injects device_token. STORE_ROOT_ENV plus
session_id (session_store_dir) picks dir. This does not read
a routine URL or a leader socket. The web machine client and the
node CLI set wake on their own open paths. The device bearer stays
in memory and is not written under dir.
Sourcepub fn connect(config: &SessionConfig) -> Result<Self, ShellError>
pub fn connect(config: &SessionConfig) -> Result<Self, ShellError>
Registers this Grok Bot web session, then opens its sealed store.
POST /client/v3/register with the derived nick, the session id, and
a public id equal to that nick. The bearer from a creating response
stays in memory. A repeat of the same session id returns no bearer;
[DEVICE_TOKEN_ENV] (already copied into config) is used instead.
One Self::drive publishes this device’s public keys. The private
Olm account stays in the store.
Sourcepub fn connect_from_env() -> Result<Self, ShellError>
pub fn connect_from_env() -> Result<Self, ShellError>
SessionConfig::from_env then Self::connect. No routine URL
and no leader socket. The web machine client is
MachineClient::from_env. The node CLI is
Self::connect_node_from_env.
Sourcepub fn connect_node_from_env() -> Result<Self, ShellError>
pub fn connect_node_from_env() -> Result<Self, ShellError>
Node CLI open path. One session from the host environment, woken by
ACP on LEADER_SOCK_ENV. ROUTINE_URL_ENV or
ROUTINE_BEARER_ENV is refused before register, is not stored, and
is not logged. This does not read a session json.
pub fn device_bearer(&self) -> &str
Sourcepub fn nick(&self) -> Option<&str>
pub fn nick(&self) -> Option<&str>
This session’s derived nick, when Self::connect stored one.
Self::open leaves this empty.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Session / device id used for the seal and for ACP sessionId.
Sourcepub fn homeserver_url(&self) -> &str
pub fn homeserver_url(&self) -> &str
Homeserver origin this store performs Client-Server calls against.
Sourcepub fn has_leader(&self) -> bool
pub fn has_leader(&self) -> bool
Whether an ACP leader socket is configured for wake.
Sourcepub fn store_dir(&self) -> &Path
pub fn store_dir(&self) -> &Path
Directory this store seals into. Not shared with another session.
Sourcepub fn homeserver_hits(&self) -> u64
pub fn homeserver_hits(&self) -> u64
Homeserver calls this store’s client has counted. In-process bus calls are not included. Zero when this store has no bus.
Sourcepub fn pushed_room_events(&self) -> &[PushedRoomEvent]
pub fn pushed_room_events(&self) -> &[PushedRoomEvent]
Room texts this session received on the machine push socket.
Sourcepub fn member_joined(&self, room_id: &str, user_id: &str) -> bool
pub fn member_joined(&self, room_id: &str, user_id: &str) -> bool
Whether user_id is a joined member of room_id in this store.
Sourcepub fn find_nick(
&mut self,
name_or_nick: &str,
now_ms: i64,
) -> Result<FoundSession, ShellError>
pub fn find_nick( &mut self, name_or_nick: &str, now_ms: i64, ) -> Result<FoundSession, ShellError>
Looks up name_or_nick in the user directory. A display name is
derived first when it is not already a nick. The hit is nick plus
user id. No routine URL is returned or sent.
Sourcepub fn ensure_dm(
&mut self,
name_or_nick: &str,
now_ms: i64,
) -> Result<String, ShellError>
pub fn ensure_dm( &mut self, name_or_nick: &str, now_ms: i64, ) -> Result<String, ShellError>
Looks name_or_nick up and opens the encrypted DM, creating it when
this account does not already have one. Does not send. The peer may
still be invited: Self::write_to_nick sends only after they join.
Sourcepub fn accept_direct_invites(
&mut self,
now_ms: i64,
) -> Result<Vec<String>, ShellError>
pub fn accept_direct_invites( &mut self, now_ms: i64, ) -> Result<Vec<String>, ShellError>
Joins direct-message invites already visible to this store.
Returns the room ids this call asked to join. A room that is not an
is_direct invite is left alone. This does not register the inviter.
Sourcepub fn write_to_nick(
&mut self,
name_or_nick: &str,
text: &str,
now_ms: i64,
) -> Result<String, ShellError>
pub fn write_to_nick( &mut self, name_or_nick: &str, text: &str, now_ms: i64, ) -> Result<String, ShellError>
Writes text to the session named by name_or_nick.
The caller is already registered. This looks the nick up, reuses the
encrypted DM when one exists, otherwise creates one, and sends only
after the peer’s membership is join. A peer who is still invited
gets no ciphertext: the caller joins them first
(Self::accept_direct_invites) and calls this again. It does not
register the other session and it does not put a routine URL in the room.
Sourcepub fn set_wake(&mut self, wake: SessionWake)
pub fn set_wake(&mut self, wake: SessionWake)
Replaces the wake targets. None or empty turns that trigger off.
The bearer is stored in Zeroizing memory and is not written to
disk. Self::open does not read a wake; the web machine client
and the node CLI set one on their open paths.
Sourcepub fn set_wake_chain(&mut self, session: ProviderSession, chain: WakeChain)
pub fn set_wake_chain(&mut self, session: ProviderSession, chain: WakeChain)
Installs the provider wake chain (provider::plan_chain). Used
only while no leader socket is set; the Grok leader path and the
routine POST are unchanged by it.
Sourcepub fn wake_chain_ids(&self) -> Vec<&'static str>
pub fn wake_chain_ids(&self) -> Vec<&'static str>
Link ids of the installed chain, in order. Empty when none.
Sourcepub fn wake_route(&self) -> Option<&str>
pub fn wake_route(&self) -> Option<&str>
<link id> delivered|queued for the newest chain wake.
Sourcepub fn take_wake_route(&mut self) -> Option<String>
pub fn take_wake_route(&mut self) -> Option<String>
Self::wake_route, cleared, so a listener prints it once.
Sourcepub fn has_routine(&self) -> bool
pub fn has_routine(&self) -> bool
Whether this store has a routine to wake (URL set).
Sourcepub fn wake_note(&self) -> Option<&str>
pub fn wake_note(&self) -> Option<&str>
Last wake failure that did not drop the room text. None if the
last attempt worked or nothing has been attempted. The bearer and
the plaintext are not included.
Sourcepub fn wake_log(&self) -> &[WakeAttempt]
pub fn wake_log(&self) -> &[WakeAttempt]
Routine POSTs this store attempted since open, oldest first. Holds the event id and the HTTP status only: no URL, key, or body.
Sourcepub fn dispatch(
&mut self,
command: MessengerCommand,
now_ms: i64,
) -> Result<(), ShellError>
pub fn dispatch( &mut self, command: MessengerCommand, now_ms: i64, ) -> Result<(), ShellError>
Queues command on the engine. It does not perform HTTP; Self::drive
does that for whatever the engine then releases.
Sourcepub fn send_room_message(
&mut self,
room_id: &str,
text: &str,
now_ms: i64,
) -> Result<Vec<OutgoingRequest>, ShellError>
pub fn send_room_message( &mut self, room_id: &str, text: &str, now_ms: i64, ) -> Result<Vec<OutgoingRequest>, ShellError>
Queues MessengerCommand::SendMessage and releases whatever the
engine will send next. That is a room send on an unencrypted room,
or the key-setup requests the engine emits first when the room is
encrypted. Nothing here calls the old mailbox. The returned requests
are already in flight; a caller that wants them performed uses
Self::drive instead of this method.
Sourcepub fn drive(
&mut self,
now_ms: i64,
wait_for_sync: bool,
) -> Result<(), ShellError>
pub fn drive( &mut self, now_ms: i64, wait_for_sync: bool, ) -> Result<(), ShellError>
Performs every released request against base_url.
/sync with timeout=0 is always waited on. A long-poll /sync is
started immediately and joined only when wait_for_sync is set, and
at most once per call, so an idle 30s poll does not run back to back
while key-setup requests are still in flight. The long-poll that is
left on the wire is the engine’s own request, including its timeout.
A homeserver that wakes that poll (this server does) delivers the
event without the shell polling twice.
Sourcepub fn texts(&self) -> Vec<TextView>
pub fn texts(&self) -> Vec<TextView>
Text-like timeline rows. Encrypted payloads that have not decrypted
are reported as undecryptable without their ciphertext.
Sourcepub fn sync_inflight(&self) -> bool
pub fn sync_inflight(&self) -> bool
HTTP status codes this store has seen, oldest first. Bodies are not kept.
pub fn http_trace(&self) -> Vec<String>
Sourcepub fn take_ingest_error(&mut self) -> Option<String>
pub fn take_ingest_error(&mut self) -> Option<String>
The last response this core failed to ingest, once.
Sourcepub fn take_security_alerts(&mut self) -> Vec<String>
pub fn take_security_alerts(&mut self) -> Vec<String>
Drains peer key-change alerts (M3).