Skip to content

Commit

Permalink
igniterealtime#166: Refactored EmptyMessageUtils into an Enum definition
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Mar 15, 2023
1 parent 7139cd4 commit a4b8788
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.jivesoftware.openfire.archive;

import org.jivesoftware.openfire.archive.EmptyMessageUtils.EmptyMessageType;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
import org.jivesoftware.openfire.interceptor.PacketInterceptor;
Expand Down Expand Up @@ -100,11 +99,11 @@ public void interceptPacket(Packet packet, Session session, boolean incoming, bo
}
else
{
EmptyMessageType emptyMessageType = EmptyMessageUtils.getMessageType(message.getElement());
EmptyMessageType emptyMessageType = EmptyMessageType.getMessageType(message.getElement());

long bitmask = conversationManager.getSpeficifEmptyMessageArchivingEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_TO_IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
{
eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
ConversationEvent.getEmptyMessageReceivedEvent(sender, receiver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class ConversationEvent {

private String nickname;

private EmptyMessageUtils.EmptyMessageType emptyMessageType;
private EmptyMessageType emptyMessageType;

/**
* Do not use this constructor. It only exists for serialization purposes.
Expand Down Expand Up @@ -198,7 +198,7 @@ public int hashCode() {
return Objects.hash(type, date, body, stanza, sender, receiver, roomJID, user, nickname);
}

public static ConversationEvent getEmptyMessageReceivedEvent(JID sender, JID receiver, EmptyMessageUtils.EmptyMessageType emptyMessageType, String stanza, Date date) {
public static ConversationEvent getEmptyMessageReceivedEvent(JID sender, JID receiver, EmptyMessageType emptyMessageType, String stanza, Date date) {
ConversationEvent event = new ConversationEvent();
event.type = Type.chatMessageReceived;
event.sender = sender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerInfo;
import org.jivesoftware.openfire.archive.EmptyMessageUtils.EmptyMessageType;
import org.jivesoftware.openfire.archive.cluster.GetConversationCountTask;
import org.jivesoftware.openfire.archive.cluster.GetConversationTask;
import org.jivesoftware.openfire.archive.cluster.GetConversationsTask;
Expand Down Expand Up @@ -870,11 +869,11 @@ else if ((date.getTime() - conversation.getLastActivity().getTime() > idleTime.t
}
else
if (isEmptyMessageArchivingEnabled()) {
EmptyMessageType emptyMessageType = EmptyMessageUtils.getMessageType(stanza);
EmptyMessageType emptyMessageType = EmptyMessageType.getMessageType(stanza);

long bitmask = getSpeficifEmptyMessageArchivingEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_TO_IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
{
messageArchiver.archive(new ArchivedMessage(conversation.getConversationID(), sender, receiver, date, body, stanza, false, null) );
}
Expand Down Expand Up @@ -946,11 +945,11 @@ else if ((date.getTime() - conversation.getLastActivity().getTime() > idleTime.t
}
else
if (isEmptyMessageArchivingForMUCEnabled()) {
EmptyMessageType emptyMessageType = EmptyMessageUtils.getMessageType(stanza);
EmptyMessageType emptyMessageType = EmptyMessageType.getMessageType(stanza);

long bitmask = getSpeficifEmptyMessageArchivingForMUCEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_TO_IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
{
messageArchiver.archive( new ArchivedMessage(conversation.getConversationID(), sender, jid, date, body, roomArchivingStanzasEnabled ? stanza : "", false, receiverIfPM));
}
Expand Down
49 changes: 24 additions & 25 deletions src/java/org/jivesoftware/openfire/archive/ConversationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.itextpdf.layout.properties.Leading;
import com.itextpdf.layout.properties.Property;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.archive.EmptyMessageUtils.EmptyMessageType;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveGlobals;
Expand Down Expand Up @@ -224,39 +223,39 @@ private ByteArrayOutputStream buildPDFContent(ConversationManager conversationMa

if (body==null&&OUTPUT_EMPTY_MESSAGES.getValue())
{
switch (EmptyMessageUtils.getMessageType(message.getStanza()))
switch (EmptyMessageType.getMessageType(message.getStanza()))
{
case TYPE_CHATMARKER_MARKABLE:
case CHATMARKER_MARKABLE:
bodyLessText="--message markable--";
break;
case TYPE_CHATMARKER_RECEIVED:
case CHATMARKER_RECEIVED:
bodyLessText="--message received XEP-0333 --";
break;
case TYPE_MESSAGE_DELIVERY_RECEIPTS_RECEIVED:
case MESSAGE_DELIVERY_RECEIPTS_RECEIVED:
bodyLessText="--message received XEP-0184 --";
break;
case TYPE_CHATMARKER_DISPLAYED:
case CHATMARKER_DISPLAYED:
bodyLessText="--message displayed--";
break;
case TYPE_CHATMARKER_ACKNOWLEDGED:
case CHATMARKER_ACKNOWLEDGED:
bodyLessText="--message acknowleged--";
break;
case TYPE_MESSAGE_RETRACTION:
case MESSAGE_RETRACTION:
bodyLessText="--message retraction: "+message.getStanza()+"--";
break;
case TYPE_CHATSTATE_NOTIFICATION_ACTIVE:
case CHATSTATE_NOTIFICATION_ACTIVE:
bodyLessText="--chatstate notification: active --";
break;
case TYPE_CHATSTATE_NOTIFICATION_COMPOSING:
case CHATSTATE_NOTIFICATION_COMPOSING:
bodyLessText="--chatstate notification: composing --";
break;
case TYPE_CHATSTATE_NOTIFICATION_PAUSED:
case CHATSTATE_NOTIFICATION_PAUSED:
bodyLessText="--chatstate notification: paused --";
break;
case TYPE_CHATSTATE_NOTIFICATION_INACTIVE:
case CHATSTATE_NOTIFICATION_INACTIVE:
bodyLessText="--chatstate notification: inactive --";
break;
case TYPE_CHATSTATE_NOTIFICATION_GONE:
case CHATSTATE_NOTIFICATION_GONE:
bodyLessText="--chatstate notification: gone --";
break;
default:
Expand Down Expand Up @@ -383,39 +382,39 @@ private ConversationInfo toConversationInfo(ConversationManager conversationMana

if (body==null&&OUTPUT_EMPTY_MESSAGES.getValue())
{
switch (EmptyMessageUtils.getMessageType(message.getStanza()))
switch (EmptyMessageType.getMessageType(message.getStanza()))
{
case TYPE_CHATMARKER_MARKABLE:
case CHATMARKER_MARKABLE:
bodyLessText="--message markable--";
break;
case TYPE_CHATMARKER_RECEIVED:
case CHATMARKER_RECEIVED:
bodyLessText="--message received XEP-0333 --";
break;
case TYPE_MESSAGE_DELIVERY_RECEIPTS_RECEIVED:
case MESSAGE_DELIVERY_RECEIPTS_RECEIVED:
bodyLessText="--message received XEP-0184 --";
break;
case TYPE_CHATMARKER_DISPLAYED:
case CHATMARKER_DISPLAYED:
bodyLessText="--message displayed--";
break;
case TYPE_CHATMARKER_ACKNOWLEDGED:
case CHATMARKER_ACKNOWLEDGED:
bodyLessText="--message acknowleged--";
break;
case TYPE_MESSAGE_RETRACTION:
case MESSAGE_RETRACTION:
bodyLessText="--message retraction: "+message.getStanza()+"--";
break;
case TYPE_CHATSTATE_NOTIFICATION_ACTIVE:
case CHATSTATE_NOTIFICATION_ACTIVE:
bodyLessText="--chatstate notification: active --";
break;
case TYPE_CHATSTATE_NOTIFICATION_COMPOSING:
case CHATSTATE_NOTIFICATION_COMPOSING:
bodyLessText="--chatstate notification: composing --";
break;
case TYPE_CHATSTATE_NOTIFICATION_PAUSED:
case CHATSTATE_NOTIFICATION_PAUSED:
bodyLessText="--chatstate notification: paused --";
break;
case TYPE_CHATSTATE_NOTIFICATION_INACTIVE:
case CHATSTATE_NOTIFICATION_INACTIVE:
bodyLessText="--chatstate notification: inactive --";
break;
case TYPE_CHATSTATE_NOTIFICATION_GONE:
case CHATSTATE_NOTIFICATION_GONE:
bodyLessText="--chatstate notification: gone --";
break;
default:
Expand Down
Loading

0 comments on commit a4b8788

Please sign in to comment.