Skip to content

Commit

Permalink
Chatlog: Handle log lines with newlines in them
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed May 18, 2024
1 parent 2ded141 commit 2cdef4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/chat-plugins/chatlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ export const LogViewer = new class {
buf += `<p class="message-error">Room "${roomid}" doesn't have logs for ${day}</p>`;
} else {
for await (const line of stream) {
buf += this.renderLine(line, opts, {roomid, date: day});
// sometimes there can be newlines in there. parse accordingly
for (const part of line.split('\n')) {
buf += this.renderLine(part, opts, {roomid, date: day});
}
}
}
buf += `</div>`;
Expand Down Expand Up @@ -816,8 +819,8 @@ export class DatabaseLogSearcher extends Searcher {
if (!Rooms.Roomlogs.table) throw new Error(`Database search made while database is disabled.`);
const results: {[date: string]: {[user: string]: number}} = {};
const [year, month] = monthString.split('-').map(Number);
const rows = await Rooms.Roomlogs.table.selectAll()`
WHERE EXTRACT("year" FROM time::DATE) = ${year} AND EXTRACT("month" FROM time::DATE) = ${month} AND
const rows = await Rooms.Roomlogs.table.selectAll()`
WHERE EXTRACT("year" FROM time::DATE) = ${year} AND EXTRACT("month" FROM time::DATE) = ${month} AND
roomid = ${roomid} AND type = ${'c'}${user ? SQL` AND userid = ${user}` : SQL``}
`;

Expand Down

0 comments on commit 2cdef4c

Please sign in to comment.