chiark / gitweb /
Retrieve extra details about your own account.
authorSimon Tatham <anakin@pobox.com>
Sat, 13 Jan 2024 10:28:49 +0000 (10:28 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 13 Jan 2024 13:15:58 +0000 (13:15 +0000)
commitefaa3c50742117f7ae65ab9c28053075f6407f13
tree15851c637b9708d84b1c5a0e57fb6c40e3e755e1
parentd3ad8f7f36cebb3f68fb614f5051121f002db4f3
Retrieve extra details about your own account.

Turns out that the API data model has two related types: 'Account',
which you can retrieve for anyone, and 'CredentialAccount' which
contains an extra sub-object full of settings you can only set (or
see) for your own account.

In another language I could make those distinct actual data types,
one a subclass of the other adding the extra field. Here, it's easier
to just fudge it a bit, pretending that all Account objects
_optionally_ have the 'source' subobject, and when called on to
retrieve our own record, always doing it via the API call that
provides the extra.

This also introduces a bit of a wrinkle about caching the result - we
_do_ also receive copies of our own Account record in other
contexts (e.g. as the author of a status we posted that reappears in a
feed), and so we have to ensure we don't use those to overwrite our
cached record to delete the source. This is ugly, but I prefer it to
the other option, which is to maintain a _separate_ cache of our own
account record with the extra data, and have to worry about which
version of the rest of it is up to date.
src/client.rs
src/types.rs