Skip to content

Commit

Permalink
filter empty conversations from search
Browse files Browse the repository at this point in the history
  • Loading branch information
mightymop authored and guusdk committed Mar 15, 2023
1 parent 7684c58 commit 974ef96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/i18n/monitoring_i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ archive.search.results.messagecount = Message Count:
archive.search.results.date = Date:
archive.search.results.duration = Duration:
archive.search.results.none = No conversations were found using the specified search criteria. Please change your search criteria and try again.
archive.search.results.archive_disabled = The messages in this conversation were not archived.
archive.search.results.archive_disabled = The messages in this conversation were not archived or do not have a readable body.
archive.search.output.emptymessages = Output messages without body.
archive.search.output.emptymessages.enable = Enable
archive.search.output.save_settings=Save
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private ByteArrayOutputStream buildPDFContent(ConversationManager conversationMa
document.add( new Paragraph().add(new Text("\n")));

final Paragraph messageParagraph = new Paragraph();
boolean foundReadableMessages = false;
for (ArchivedMessage message : conversation.getMessages(conversationManager))
{
String time = JiveGlobals.formatTime(message.getSentDate());
Expand Down Expand Up @@ -266,6 +267,7 @@ private ByteArrayOutputStream buildPDFContent(ConversationManager conversationMa

if (bodyLessText!=null||body!=null)
{
foundReadableMessages=true;
if (!message.isRoomEvent()) {
/*
* If body is null, we add the resource to see which device has sent the message.
Expand Down Expand Up @@ -294,6 +296,13 @@ private ByteArrayOutputStream buildPDFContent(ConversationManager conversationMa
messageParagraph.add(new Text("\n"));
}
}


if (conversation.getMessages(conversationManager).size() == 0||!foundReadableMessages) {
messageParagraph.add(new Text(LocaleUtils.getLocalizedString("archive.search.results.archive_disabled",
MonitoringConstants.NAME) ));
messageParagraph.add(new Text("\n"));
}

document.add(messageParagraph);

Expand Down Expand Up @@ -353,6 +362,7 @@ private ConversationInfo toConversationInfo(ConversationManager conversationMana
info.setDate(JiveGlobals.formatDateTime(conversation.getStartDate()));
info.setLastActivity(JiveGlobals.formatTime(conversation.getLastActivity()));
// Create body.
boolean foundReadableMessages = false;
final StringBuilder builder = new StringBuilder();
builder.append("<table width=100%>");
for (ArchivedMessage message : conversation.getMessages(conversationManager)) {
Expand Down Expand Up @@ -416,6 +426,7 @@ private ConversationInfo toConversationInfo(ConversationManager conversationMana

if (bodyLessText!=null||body!=null)
{
foundReadableMessages=true;
builder.append("<tr valign=top>");
if (!message.isRoomEvent()) {
builder.append("<td width=1% nowrap class=" + cssLabel + ">").append("[").append(time).append("]").append("</td>");
Expand All @@ -434,7 +445,7 @@ private ConversationInfo toConversationInfo(ConversationManager conversationMana
}
}

if (conversation.getMessages(conversationManager).size() == 0) {
if (conversation.getMessages(conversationManager).size() == 0||!foundReadableMessages) {
builder.append("<span class=small-description>" +
LocaleUtils.getLocalizedString("archive.search.results.archive_disabled",
MonitoringConstants.NAME) +
Expand Down
6 changes: 6 additions & 0 deletions src/web/archive-search.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@
i++;
continue;
}
if (conversation.getMessages(conversationManager).size() == 0)
{
continue;
}
Map<String, JID> participants = getParticipants(conversation);
String color = "#FFFFFF";
if (i % 2 == 0) {
Expand Down

0 comments on commit 974ef96

Please sign in to comment.