CHUI-325 FIXED (Cap conversation log to 30 days, purge older data on login)

- Remove conversations older than 30 days from call log
meow-7.2.2
Paul ProductEngine 2012-09-07 21:35:08 +03:00
parent 3cf624b371
commit 42dbf23dc5
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -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.
*/