diff options
-rw-r--r-- | telepathy-logger/text-channel.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/telepathy-logger/text-channel.c b/telepathy-logger/text-channel.c index a2c7f5e..d777553 100644 --- a/telepathy-logger/text-channel.c +++ b/telepathy-logger/text-channel.c @@ -445,13 +445,38 @@ on_message_received_cb (TpTextChannel *text_chan, TplEntity *sender; if (priv->is_chatroom) - receiver = priv->remote; + { + receiver = priv->remote; + + sender = tpl_entity_new_from_tp_contact ( + tp_signalled_message_get_sender (TP_MESSAGE (message)), + TPL_ENTITY_CONTACT); + } else - receiver = priv->self; + { + const gchar *sender_nick; + + /* First try and get the sender-nickname from the message + * headers. If it's there then create a contact entity to get + * its alias. If not then just use the contact we've already + * prepared and got an alias for. */ + sender_nick = tp_asv_get_string (tp_message_peek (TP_MESSAGE (message), 0), + "sender-nickname"); + + if (sender_nick == NULL) + { + /* Fall back to the contact we prepared ages ago. */ + sender = g_object_ref (priv->remote); + } + else + { + /* Use sender-nickname. */ + sender = tpl_entity_new (tpl_entity_get_identifier (priv->remote), + TPL_ENTITY_CONTACT, sender_nick, NULL); + } - sender = tpl_entity_new_from_tp_contact ( - tp_signalled_message_get_sender (TP_MESSAGE (message)), - TPL_ENTITY_CONTACT); + receiver = priv->self; + } tpl_text_channel_store_message (self, TP_MESSAGE (message), sender, receiver); |