1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-09-28 19:16:51 +02:00

Refactor peer-specific commands

This takes into account the possibility of multiple peers in
the group using the same nick. The /whois command now lists
all peers associated with the input name, and all commands
that target a peer with a non-unique nick will require the
public key to be used.
This commit is contained in:
jfreegman
2021-12-03 10:45:26 -05:00
parent cd4a5e5fde
commit f786b7ae6a
3 changed files with 151 additions and 108 deletions

View File

@@ -78,12 +78,18 @@ void groupchat_onGroupModeration(ToxWindow *self, Tox *m, uint32_t groupnumber,
void groupchat_rejoin(ToxWindow *self, Tox *m);
/* Gets the peer_id associated with nick.
/* Puts the peer_id associated with `identifier` in `peer_id`. The string may be
* either a nick or a public key.
*
* Returns 0 on success.
* Returns -1 on failure or if nick is not assigned to anyone in the group.
* On failure, `peer_id` is set to (uint32_t)-1.
*
* This function is intended to be a helper for groupchat_commands.c and will print
* error messages to `self`.
* Return 0 on success.
* Return -1 if the identifier does not correspond with a peer in the group.
* Return -2 if the identifier is a nick and the nick is in use by multiple peers.
*/
int group_get_nick_peer_id(uint32_t groupnumber, const char *nick, uint32_t *peer_id);
int group_get_peer_id_of_identifier(ToxWindow *self, const char *identifier, uint32_t *peer_id);
/* Gets the peer_id associated with `public_key`.
*