summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llconversationlog.cpp22
-rw-r--r--indra/newview/llconversationlog.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index e80a709203..cc02e18698 100644
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -30,6 +30,8 @@
#include "llconversationlog.h"
#include "lltrans.h"
+const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days by spec
+
struct Conversation_params
{
Conversation_params(time_t time)
@@ -139,6 +141,14 @@ const std::string LLConversation::createTimestamp(const time_t& utc_time)
return timeStr;
}
+bool LLConversation::isOlderThan(U32 days) const
+{
+ time_t now = time_corrected();
+ U32 age = (U32)((now - mTime) / SEC_PER_DAY); // age of conversation in days
+
+ return age > days;
+}
+
void LLConversation::setListenIMFloaterOpened()
{
LLIMFloater* floater = LLIMFloater::findInstance(mSessionID);
@@ -394,10 +404,22 @@ bool LLConversationLog::loadFromFile(const std::string& filename)
params.mHistoryFileName = std::string(history_file_name);
LLConversation conversation(params);
+
+ // CHUI-325
+ // The conversation log should be capped to the last 30 days. Conversations with the last utterance
+ // being over 30 days old should be purged from the conversation log text file on login.
+ if (conversation.isOlderThan(CONVERSATION_LIFETIME))
+ {
+ continue;
+ }
+
mConversations.push_back(conversation);
}
fclose(fp);
+ LLFile::remove(filename);
+ cache();
+
notifyObservers();
return true;
}
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 0d7f0080e5..16be37d67a 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -64,6 +64,8 @@ public:
void setIsPast (bool is_past) { mIsConversationPast = is_past; }
void setConverstionName(std::string conv_name) { mConversationName = conv_name; }
+ bool isOlderThan(U32 days) const;
+
/*
* Resets flag of unread offline message to false when im floater with this conversation is opened.
*/