oxen-io / libsession-util

Session utilities library
GNU General Public License v3.0
15 stars 16 forks source link

Conversations #11

Closed jagerman closed 1 year ago

jagerman commented 1 year ago

Adds Conversation config messages.

Still TODO:

majestrate commented 1 year ago

On Fri, 20 Jan 2023 14:58:39 -0800 Jason Rhinelander @.***> wrote:

@jagerman commented on this pull request.

+/// +/// convo_one_to_one c1; +/// convos_iterator it = convos_iterator_new(my_convos); +/// while (!convos_iterator_done(it)) { +/// if (convo_it_is_1to1(it, &c1)) { +/// bool should_delete = / ... */; +/// if (should_delete) +/// convos_iterator_erase(it); +/// else +/// convos_iterator_advance(it); +/// } +/// } +/// convos_iterator_free(it); +/// + +typedef struct convos_iterator {

Why? Just to make it opaque?

yes, with a C api a sign of a good design is that things that CAN be opaque are always made opaque.

the only time i'd see a need to expose internals like that is when we need to know the size of the struct or we have public members on the struct we want callers to get at.

none of those are in play on this one so it's better to make it opaque.

-- ~jeff

majestrate commented 1 year ago

On Sun, 22 Jan 2023 13:58:41 -0800 Jason Rhinelander @.***> wrote:

@jagerman commented on this pull request.

+ + +typedef struct convo_one_to_one {

  • char session_id[67]; // in hex; 66 hex chars + null terminator.
  • // milliseconds since unix epoch:
  • int64_t last_read;
  • // expiration mode & time:
  • CONVO_EXPIRATION_MODE exp_mode;
  • int64_t exp_minutes; +} convo_one_to_one;
  • +typedef struct convo_open_group {

  • const char* base_url; // null-terminated, always lower-case
  • const char* room; // null-terminated, always lower-case

Although thinking about it some more, perhaps rather than storing URL

  • room + pubkey we should just store a (smaller) hash of that in here to keep size reduced.

So you'd go pull your list of open groups from the Groups config, then would look up H(url | room | pubkey) in here.

this kind of optimizatgion has caused issues in the past (desktop session). i think doing a (pubkey, room) tuple as the lookup key would be better but at least please omit the url part of it.

-- ~jeff