Bug 1718317 - Remove always set group-by-day option in chat logging infrastructure. r=freaktechnik
This commit is contained in:
Родитель
aa59776314
Коммит
73193764ce
|
@ -63,13 +63,12 @@ interface imILogger: nsISupports {
|
|||
|
||||
// Below methods return promises that resolve to {imILog[]}.
|
||||
|
||||
jsval getLogsForContact(in imIContact aContact,
|
||||
[optional] in boolean aGroupByDay);
|
||||
|
||||
jsval getLogsForConversation(in prplIConversation aConversation,
|
||||
[optional] in boolean aGroupByDay);
|
||||
jsval getSimilarLogs(in imILog aLog,
|
||||
[optional] in boolean aGroupByDay);
|
||||
// Get logs for a contact.
|
||||
jsval getLogsForContact(in imIContact aContact);
|
||||
// Get logs for a conversation.
|
||||
jsval getLogsForConversation(in prplIConversation aConversation);
|
||||
// Get logs that are from the same conversation.
|
||||
jsval getSimilarLogs(in imILog aLog);
|
||||
|
||||
// Asynchronously iterates through log folders for all prpls and accounts and
|
||||
// invokes the callback on every log file. Returns a promise that resolves when
|
||||
|
|
|
@ -602,6 +602,10 @@ Log.prototype = {
|
|||
* @returns {imILog[]} Logs, ordered by day.
|
||||
*/
|
||||
function logsGroupedByDay(aEntries) {
|
||||
if (!Array.isArray(aEntries)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let entries = {};
|
||||
for (let path of aEntries) {
|
||||
let [logDate, logFormat] = getDateFromFilename(PathUtils.filename(path));
|
||||
|
@ -696,25 +700,6 @@ Logger.prototype = {
|
|||
return new Log(relevantEntries);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to produce array of imILog objects from directory entries.
|
||||
*
|
||||
* @param {string[]} entries - Array of paths of log files to be parsed.
|
||||
* @param {boolean} groupByDay - If true, order by day (rather than by filename).
|
||||
* @returns {imILog[]} Logs, ordered by day.
|
||||
*/
|
||||
_toLogArray(entries, groupByDay) {
|
||||
if (!Array.isArray(entries)) {
|
||||
return [];
|
||||
}
|
||||
if (groupByDay) {
|
||||
return logsGroupedByDay(entries);
|
||||
}
|
||||
// Default - sort by filename.
|
||||
entries.sort((a, b) => PathUtils.filename(a) > PathUtils.filename(b));
|
||||
return entries.map(path => new Log(path));
|
||||
},
|
||||
|
||||
async getLogPathsForConversation(aConversation) {
|
||||
let writer = gLogWritersById.get(aConversation.id);
|
||||
// Resolve to null if we haven't created a LogWriter yet for this conv, or
|
||||
|
@ -730,7 +715,7 @@ Logger.prototype = {
|
|||
}
|
||||
return paths;
|
||||
},
|
||||
async getLogsForContact(aContact, aGroupByDay) {
|
||||
async getLogsForContact(aContact) {
|
||||
let entries = [];
|
||||
for (let buddy of aContact.getBuddies()) {
|
||||
for (let accountBuddy of buddy.getAccountBuddies()) {
|
||||
|
@ -742,19 +727,19 @@ Logger.prototype = {
|
|||
);
|
||||
}
|
||||
}
|
||||
return this._toLogArray(entries, aGroupByDay);
|
||||
return logsGroupedByDay(entries);
|
||||
},
|
||||
getLogsForConversation(aConversation, aGroupByDay) {
|
||||
getLogsForConversation(aConversation) {
|
||||
let name = aConversation.normalizedName;
|
||||
if (aConversation.isChat) {
|
||||
name += ".chat";
|
||||
}
|
||||
|
||||
return this._getLogEntries(aConversation.account, name).then(aEntries =>
|
||||
this._toLogArray(aEntries, aGroupByDay)
|
||||
return this._getLogEntries(aConversation.account, name).then(entries =>
|
||||
logsGroupedByDay(entries)
|
||||
);
|
||||
},
|
||||
async getSimilarLogs(aLog, aGroupByDay) {
|
||||
async getSimilarLogs(aLog) {
|
||||
let entries;
|
||||
try {
|
||||
entries = await IOUtils.getChildren(PathUtils.parent(aLog.path));
|
||||
|
@ -764,7 +749,7 @@ Logger.prototype = {
|
|||
);
|
||||
}
|
||||
// If there was an error, this will return an empty array.
|
||||
return this._toLogArray(entries, aGroupByDay);
|
||||
return logsGroupedByDay(entries);
|
||||
},
|
||||
|
||||
getLogFolderPathForAccount(aAccount) {
|
||||
|
|
|
@ -393,18 +393,6 @@ var test_logging = async function() {
|
|||
}
|
||||
};
|
||||
|
||||
let logs = await logger.getLogsForConversation(dummyConv);
|
||||
let allLogMsgs = [];
|
||||
for (let log of logs) {
|
||||
let conv = await log.getConversation();
|
||||
if (!conv) {
|
||||
continue;
|
||||
}
|
||||
allLogMsgs = allLogMsgs.concat(conv.getMessages());
|
||||
}
|
||||
// Two session messages, one for each valid log file.
|
||||
testMsgs(allLogMsgs, firstDayMsgs.concat(secondDayMsgs), 2);
|
||||
|
||||
// Accepts time in seconds, reduces it to a date, and returns the value in millis.
|
||||
let reduceTimeToDate = function(aTime) {
|
||||
let date = new Date(aTime * 1000);
|
||||
|
@ -419,7 +407,7 @@ var test_logging = async function() {
|
|||
messagesByDay.set(reduceTimeToDate(firstDayMsgs[0].time), firstDayMsgs);
|
||||
messagesByDay.set(reduceTimeToDate(secondDayMsgs[0].time), secondDayMsgs);
|
||||
|
||||
logs = await logger.getLogsForConversation(dummyConv, true);
|
||||
let logs = await logger.getLogsForConversation(dummyConv);
|
||||
for (let log of logs) {
|
||||
let conv = await log.getConversation();
|
||||
let date = reduceTimeToDate(log.time);
|
||||
|
|
|
@ -887,7 +887,7 @@ var chatHandler = {
|
|||
...path.split("/")
|
||||
);
|
||||
imServices.logs.getLogFromFile(path, true).then(aLog => {
|
||||
imServices.logs.getSimilarLogs(aLog, true).then(aSimilarLogs => {
|
||||
imServices.logs.getSimilarLogs(aLog).then(aSimilarLogs => {
|
||||
if (contactlistbox.selectedItem != item) {
|
||||
return;
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ var chatHandler = {
|
|||
|
||||
ChatEncryption.updateEncryptionButton(document, item.conv);
|
||||
|
||||
imServices.logs.getLogsForConversation(item.conv, true).then(aLogs => {
|
||||
imServices.logs.getLogsForConversation(item.conv).then(aLogs => {
|
||||
if (contactlistbox.selectedItem != item) {
|
||||
return;
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ var chatHandler = {
|
|||
e.setAttribute("hidden", "true");
|
||||
});
|
||||
|
||||
imServices.logs.getLogsForContact(contact, true).then(aLogs => {
|
||||
imServices.logs.getLogsForContact(contact).then(aLogs => {
|
||||
if (contactlistbox.selectedItem != item) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче