Skip to content

0.3.0: media messages, room/bot lifecycle, state + account data, devices#14

Merged
TroyHernandez merged 9 commits into
mainfrom
feature/api-0.3.0
Jun 10, 2026
Merged

0.3.0: media messages, room/bot lifecycle, state + account data, devices#14
TroyHernandez merged 9 commits into
mainfrom
feature/api-0.3.0

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Batches every known gap into one CRAN slot (one endpoint family per commit for review):

  1. State + account datamx_get_state() (read-side of mx_set_state(); returns NULL on M_NOT_FOUND), generic mx_get_account_data() / mx_set_account_data().
  2. Media messagesmx_send_media() (upload + post) with mx_send_file/image/audio/video() wrappers. Metadata beyond mimetype/size is caller-supplied; no media-inspection deps.
  3. Profile / invite / redact / typingmx_profile()", mx_set_displayname(), mx_set_avatar_url(), mx_room_invite(), mx_redact(), mx_typing()`.
  4. Devicesmx_devices(), mx_delete_device(auth = NULL) passing UIA payloads through verbatim (no automated reauth).
  5. Docs + version — README refresh (was still describing the pre-0.2.0 delta), NEWS for 0.3.0 incl. the Add mx_send_event() and mx_set_state() generic senders #13 senders, bump to 0.3.0.

Verified: suite 169/0; R CMD check --as-cran 0/0/0; every new endpoint exercised live against Conduit, including the documented 401→auth retry on device deletion.

Boundary note: everything here is a stateless single-endpoint wrapper (mx_send_media composes two of its own endpoints, still zero state) — the stateful/orchestration layer stays in mx.client.

mx_get_state() is the read-side counterpart of mx_set_state() (e.g.
check m.room.encryption before joining the send path); both it and
mx_get_account_data() return NULL on M_NOT_FOUND rather than erroring.
Account data stays generic (type + content) -- no DM-semantics helpers.
Generic upload-then-post: mx_upload() to the media repo, then an
m.room.message with url + info (mimetype, size). Sugar wrappers fix the
msgtype. Richer metadata (dimensions, duration) is caller-supplied via
info -- no media-inspection dependencies.
mx_profile() reads displayname/avatar_url; mx_set_displayname() and
mx_set_avatar_url() let a bot dress itself after mx_upload().
mx_room_invite() covers inviting into an existing room (creation-time
invites already existed). mx_redact() is Matrix deletion, rounding out
reactions. mx_typing() shows/clears the typing indicator while a slow
reply generates.
Listing is a plain GET. Deletion passes any user-interactive auth
payload through verbatim and documents the 401-then-retry dance; mx.api
deliberately does not automate the password exchange (that needs stored
credentials, which is client-layer state).
README: refresh the stale dev-version references (was still describing
the pre-0.2.0 delta), extend the coverage table with the new endpoint
families, and point the E2EE framing at mx.client as the stateful
integration layer. NEWS: 0.3.0 entry covering the full batch, including
mx_send_event()/mx_set_state() from #13 which never got an entry.
…onfig()

mx_send_media(msgtype = NULL) now derives m.image/m.audio/m.video from
the MIME family, so pointing it at a file just works. mx_guess_mime()
is exported so callers don't maintain their own extension table.
mx_media_config() asks the server for its upload cap (m.upload.size),
v1 endpoint with legacy fallback.
All HTTP failures now signal a condition classed
c("mx_error_<ERRCODE>", "mx_error", "error"), carrying $errcode,
$status, and the parsed $body, so code can react to specific failures
(tryCatch(..., mx_error_M_UNKNOWN_TOKEN = relogin)) instead of grepling
the message. Message text keeps the historical "Matrix error [CODE]:
msg" shape, so string-matching callers keep working. mx_get_state()
and mx_get_account_data() now catch by class.
mx_upload() read the whole file into RAM before sending; switch to
curl upload mode with a readfunction so multi-GB files stream from a
connection (customrequest keeps the method POST). Verified live with an
8MB byte-identical round-trip.

mx_guess_mime() returned NA instead of the documented octet-stream
fallback on unknown extensions (named-vector miss is NA, not NULL, so
%||% never fired) -- now load-bearing for msgtype auto-detection.
@TroyHernandez TroyHernandez merged commit 618c33d into main Jun 10, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the feature/api-0.3.0 branch June 10, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant