mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Fix carbon logging
Regards https://github.com/profanity-im/profanity/issues/1342
This commit is contained in:
parent
d240eb629c
commit
d4692b1b2d
@ -164,12 +164,16 @@ log_database_close(void)
|
|||||||
void
|
void
|
||||||
log_database_add_incoming(ProfMessage *message)
|
log_database_add_incoming(ProfMessage *message)
|
||||||
{
|
{
|
||||||
|
if (message->to_jid) {
|
||||||
|
_add_to_db(message, NULL, message->from_jid, message->to_jid);
|
||||||
|
} else {
|
||||||
const char *jid = connection_get_fulljid();
|
const char *jid = connection_get_fulljid();
|
||||||
Jid *myjid = jid_create(jid);
|
Jid *myjid = jid_create(jid);
|
||||||
|
|
||||||
_add_to_db(message, NULL, message->from_jid, myjid);
|
_add_to_db(message, NULL, message->from_jid, myjid);
|
||||||
|
|
||||||
jid_destroy(myjid);
|
jid_destroy(myjid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -440,20 +440,19 @@ sv_ev_delayed_private_message(ProfMessage *message)
|
|||||||
void
|
void
|
||||||
sv_ev_outgoing_carbon(ProfMessage *message)
|
sv_ev_outgoing_carbon(ProfMessage *message)
|
||||||
{
|
{
|
||||||
ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid);
|
ProfChatWin *chatwin = wins_get_chat(message->to_jid->barejid);
|
||||||
if (!chatwin) {
|
if (!chatwin) {
|
||||||
chatwin = chatwin_new(message->from_jid->barejid);
|
chatwin = chatwin_new(message->to_jid->barejid);
|
||||||
}
|
}
|
||||||
|
|
||||||
chat_state_active(chatwin->state);
|
chat_state_active(chatwin->state);
|
||||||
|
|
||||||
//TODO: check whether we need to change from and to for carbon. now that we have profmessage->to_jid?
|
|
||||||
if (message->plain) {
|
if (message->plain) {
|
||||||
if (message->type == PROF_MSG_TYPE_MUCPM) {
|
if (message->type == PROF_MSG_TYPE_MUCPM) {
|
||||||
// MUC PM, should have resource (nick) in filename
|
// MUC PM, should have resource (nick) in filename
|
||||||
chat_log_msg_out(message->from_jid->barejid, message->plain, message->from_jid->resourcepart);
|
chat_log_msg_out(message->to_jid->barejid, message->plain, message->from_jid->resourcepart);
|
||||||
} else {
|
} else {
|
||||||
chat_log_msg_out(message->from_jid->barejid, message->plain, NULL);
|
chat_log_msg_out(message->to_jid->barejid, message->plain, NULL);
|
||||||
}
|
}
|
||||||
log_database_add_incoming(message);
|
log_database_add_incoming(message);
|
||||||
}
|
}
|
||||||
@ -782,7 +781,6 @@ sv_ev_incoming_message(ProfMessage *message)
|
|||||||
void
|
void
|
||||||
sv_ev_incoming_carbon(ProfMessage *message)
|
sv_ev_incoming_carbon(ProfMessage *message)
|
||||||
{
|
{
|
||||||
//TODO: check whether we need to change from and to for carbon. now that we have profmessage->to_jid?
|
|
||||||
gboolean new_win = FALSE;
|
gboolean new_win = FALSE;
|
||||||
ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid);
|
ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid);
|
||||||
if (!chatwin) {
|
if (!chatwin) {
|
||||||
|
@ -1118,6 +1118,7 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
const gchar *from = xmpp_stanza_get_from(message_stanza);
|
const gchar *from = xmpp_stanza_get_from(message_stanza);
|
||||||
|
|
||||||
// happens when receive a carbon of a self sent message
|
// happens when receive a carbon of a self sent message
|
||||||
|
// really? maybe some servers do this, but it's not required.
|
||||||
if (!to) to = from;
|
if (!to) to = from;
|
||||||
|
|
||||||
Jid *jid_from = jid_create(from);
|
Jid *jid_from = jid_create(from);
|
||||||
@ -1140,18 +1141,19 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
message->encrypted = xmpp_stanza_get_text(x);
|
message->encrypted = xmpp_stanza_get_text(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: now that profmessage has from_jid AND to_jid we should save both. and maybe also add is_carbon so we can decide later on.
|
//TODO: maybe also add is_carbon maybe even an enum with outgoing/incoming
|
||||||
|
//could be that then we can have sv_ev_carbon no incoming/outgoing
|
||||||
if (message->plain || message->encrypted || message->body) {
|
if (message->plain || message->encrypted || message->body) {
|
||||||
// if we are the recipient, treat as standard incoming message
|
// if we are the recipient, treat as standard incoming message
|
||||||
if (g_strcmp0(mybarejid, jid_to->barejid) == 0) {
|
if (g_strcmp0(mybarejid, jid_to->barejid) == 0) {
|
||||||
jid_destroy(jid_to);
|
|
||||||
message->from_jid = jid_from;
|
message->from_jid = jid_from;
|
||||||
|
message->to_jid = jid_to;
|
||||||
sv_ev_incoming_carbon(message);
|
sv_ev_incoming_carbon(message);
|
||||||
|
|
||||||
// else treat as a sent message
|
// else treat as a sent message
|
||||||
} else {
|
} else {
|
||||||
jid_destroy(jid_from);
|
message->from_jid = jid_from;
|
||||||
message->from_jid = jid_to;
|
message->to_jid = jid_to;
|
||||||
sv_ev_outgoing_carbon(message);
|
sv_ev_outgoing_carbon(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user