mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Implemented chat logging options for OTR messages
on - Log OTR messages as plaintext off - Do not log OTR messages redact - Log, but replace the text with '[redacted]' Defaults to redact
This commit is contained in:
parent
60820007ee
commit
ecf323de31
@ -1176,7 +1176,11 @@ cmd_execute_default(const char * const inp)
|
||||
if (prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
chat_log_chat(jidp->barejid, recipient, inp, PROF_OUT_LOG, NULL);
|
||||
if (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0) {
|
||||
chat_log_chat(jidp->barejid, recipient, inp, PROF_OUT_LOG, NULL);
|
||||
} else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
|
||||
chat_log_chat(jidp->barejid, recipient, "[redacted]", PROF_OUT_LOG, NULL);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
|
||||
|
@ -929,7 +929,11 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
||||
if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) {
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
|
||||
if (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0) {
|
||||
chat_log_chat(jidp->barejid, usr_jid, msg, PROF_OUT_LOG, NULL);
|
||||
} else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
|
||||
chat_log_chat(jidp->barejid, usr_jid, "[redacted]", PROF_OUT_LOG, NULL);
|
||||
}
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
} else {
|
||||
|
@ -429,14 +429,14 @@ otr_encrypt_message(const char * const to, const char * const message)
|
||||
}
|
||||
|
||||
char *
|
||||
otr_decrypt_message(const char * const from, const char * const message)
|
||||
otr_decrypt_message(const char * const from, const char * const message, gboolean *was_decrypted)
|
||||
{
|
||||
char *decrypted = NULL;
|
||||
OtrlTLV *tlvs = NULL;
|
||||
OtrlTLV *tlv = NULL;
|
||||
int result = otrl_message_receiving(user_state, &ops, NULL, jid, "xmpp", from, message, &decrypted, &tlvs, NULL, NULL);
|
||||
|
||||
// internal libotr message, ignore
|
||||
// internal libotr message
|
||||
if (result == 1) {
|
||||
tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
|
||||
if (tlv) {
|
||||
@ -452,10 +452,12 @@ otr_decrypt_message(const char * const from, const char * const message)
|
||||
|
||||
// message was decrypted, return to user
|
||||
} else if (decrypted != NULL) {
|
||||
*was_decrypted = TRUE;
|
||||
return decrypted;
|
||||
|
||||
// normal non OTR message
|
||||
} else {
|
||||
*was_decrypted = FALSE;
|
||||
return strdup(message);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,8 @@ char * otr_get_my_fingerprint(void);
|
||||
char * otr_get_their_fingerprint(const char * const recipient);
|
||||
|
||||
char * otr_encrypt_message(const char * const to, const char * const message);
|
||||
char * otr_decrypt_message(const char * const from, const char * const message);
|
||||
char * otr_decrypt_message(const char * const from, const char * const message,
|
||||
gboolean *was_decrypted);
|
||||
|
||||
void otr_free_message(char *message);
|
||||
|
||||
|
@ -176,9 +176,12 @@ void
|
||||
handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
{
|
||||
#ifdef HAVE_LIBOTR
|
||||
gboolean was_decrypted = FALSE;
|
||||
char *newmessage;
|
||||
if (!priv) {
|
||||
newmessage = otr_decrypt_message(from, message);
|
||||
newmessage = otr_decrypt_message(from, message, &was_decrypted);
|
||||
|
||||
// internal OTR message
|
||||
if (newmessage == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -193,7 +196,13 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
Jid *from_jid = jid_create(from);
|
||||
const char *jid = jabber_get_fulljid();
|
||||
Jid *jidp = jid_create(jid);
|
||||
chat_log_chat(jidp->barejid, from_jid->barejid, newmessage, PROF_IN_LOG, NULL);
|
||||
|
||||
if (!was_decrypted || (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0)) {
|
||||
chat_log_chat(jidp->barejid, from_jid->barejid, newmessage, PROF_IN_LOG, NULL);
|
||||
} else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) {
|
||||
chat_log_chat(jidp->barejid, from_jid->barejid, "[redacted]", PROF_IN_LOG, NULL);
|
||||
}
|
||||
|
||||
jid_destroy(jidp);
|
||||
jid_destroy(from_jid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user