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 committed Feb 4, 2022
1 parent 26f6ae1 commit ec6ee76
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 @@ -151,7 +151,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 @@ -213,6 +213,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 @@ -271,6 +272,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 @@ -299,6 +301,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 @@ -358,6 +367,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 @@ -421,6 +431,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 @@ -439,7 +450,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 @@ -745,6 +745,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 ec6ee76

Please sign in to comment.