mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-25 23:13:04 +01:00
Re-implement group nick change notifications
This commit is contained in:
parent
bc3ffac0ba
commit
2710ab6034
@ -404,7 +404,37 @@ static void groupchat_onGroupNameListChange(ToxWindow *self, Tox *m, uint32_t gr
|
|||||||
static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t groupnum, uint32_t peernum,
|
static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t groupnum, uint32_t peernum,
|
||||||
const char *name, size_t length)
|
const char *name, size_t length)
|
||||||
{
|
{
|
||||||
// TODO: this is dumb because toxcore is dumb so make it not dumb pls
|
if (self->num != groupnum) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupChat *chat = &groupchats[groupnum];
|
||||||
|
|
||||||
|
if (!chat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < chat->max_idx; ++i) {
|
||||||
|
GroupPeer *peer = &chat->peer_list[i];
|
||||||
|
|
||||||
|
// Test against default tox name to prevent nick change spam on initial join (TODO: this is disgusting)
|
||||||
|
if (peer->active && peer->peernumber == peernum && strcmp(peer->name, "Tox User")) {
|
||||||
|
ChatContext *ctx = self->chatwin;
|
||||||
|
char timefrmt[TIME_STR_SIZE];
|
||||||
|
get_time_str(timefrmt, sizeof(timefrmt));
|
||||||
|
|
||||||
|
char tmp_event[TOXIC_MAX_NAME_LENGTH * 2 + 32];
|
||||||
|
snprintf(tmp_event, sizeof(tmp_event), "is now known as %s", (char *) name);
|
||||||
|
|
||||||
|
write_to_log(tmp_event, peer->name, ctx->log, true);
|
||||||
|
line_info_add(self, timefrmt, peer->name, (char *) name, NAME_CHANGE, 0, 0, " is now known as ");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
groupchat_onGroupNameListChange(self, m, groupnum);
|
groupchat_onGroupNameListChange(self, m, groupnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +189,15 @@ void on_group_namelistchange(Tox *m, uint32_t groupnumber, void *userdata)
|
|||||||
void on_group_peernamechange(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *name,
|
void on_group_peernamechange(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *name,
|
||||||
size_t length, void *userdata)
|
size_t length, void *userdata)
|
||||||
{
|
{
|
||||||
|
char nick[TOXIC_MAX_NAME_LENGTH + 1];
|
||||||
|
length = copy_tox_str(nick, sizeof(nick), (const char *) name, length);
|
||||||
|
filter_str(nick, length);
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||||
if (windows[i].onGroupPeerNameChange != NULL)
|
if (windows[i].onGroupPeerNameChange != NULL)
|
||||||
windows[i].onGroupPeerNameChange(&windows[i], m, groupnumber, peernumber, (char *) name, length);
|
windows[i].onGroupPeerNameChange(&windows[i], m, groupnumber, peernumber, nick, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user