- this_im->lastmsg = time(NULL); /* Touch the timestamp so we know when to flush */
- StrBufAppendBufPlain(this_im->conversation, HKEY("<p><b>"), 0);
- StrBufAppendBufPlain(this_im->conversation, me->user.fullname, -1, 0);
- StrBufAppendBufPlain(this_im->conversation, HKEY(":</b> "), 0);
- StrEscAppend(this_im->conversation, NULL, msgtext, 0, 0);
- StrBufAppendBufPlain(this_im->conversation, HKEY("</p>\r\n"), 0);
+
+ /* Since it's possible for this function to get called more than once if a user is logged
+ * in on multiple sessions, we use the message's serial number to keep track of whether
+ * we've already logged it.
+ */
+ if (this_im->last_serial != serial_number)
+ {
+ this_im->lastmsg = time(NULL); /* Touch the timestamp so we know when to flush */
+ this_im->last_serial = serial_number;
+ StrBufAppendBufPlain(this_im->conversation, HKEY("<p><b>"), 0);
+ StrBufAppendBufPlain(this_im->conversation, me->user.fullname, -1, 0);
+ StrBufAppendBufPlain(this_im->conversation, HKEY(":</b> "), 0);
+ StrEscAppend(this_im->conversation, NULL, msgtext, 0, 0);
+ StrBufAppendBufPlain(this_im->conversation, HKEY("</p>\r\n"), 0);
+ }