Skip to content

Commit

Permalink
igniterealtime#166: Refactor pubsub event type into a generic 'never-…
Browse files Browse the repository at this point in the history
…store-this' type
  • Loading branch information
guusdk committed Mar 15, 2023
1 parent d2e154c commit 7139cd4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void interceptPacket(Packet packet, Session session, boolean incoming, bo

long bitmask = conversationManager.getSpeficifEmptyMessageArchivingEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_EVENT && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.TYPE_TO_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 @@ -874,7 +874,7 @@ else if ((date.getTime() - conversation.getLastActivity().getTime() > idleTime.t

long bitmask = getSpeficifEmptyMessageArchivingEnabled();

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

long bitmask = getSpeficifEmptyMessageArchivingForMUCEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_EVENT && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.TYPE_TO_IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
{
messageArchiver.archive( new ArchivedMessage(conversation.getConversationID(), sender, jid, date, body, roomArchivingStanzasEnabled ? stanza : "", false, receiverIfPM));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public class EmptyMessageUtils {
private static final Logger Log = LoggerFactory.getLogger(EmptyMessageUtils.class);

public enum EmptyMessageType {
TYPE_EVENT(-1),

/**
* A generic type that signifies that the type of the message child element is recognized, but must never be
* saved in a message archive. For example: Pubsub event messages.
*/
TYPE_TO_IGNORE(-1),
TYPE_UNKNOWN(1),

TYPE_CHATMARKER_MARKABLE(2), //XMLNS = urn:xmpp:chat-markers:0
Expand Down Expand Up @@ -61,7 +66,7 @@ public static EmptyMessageType getMessageType(Element stanza)
{
if (stanza.selectSingleNode("//*[local-name()='event' and namespace-uri()='http://jabber.org/protocol/pubsub#event']")!=null)
{
return EmptyMessageType.TYPE_EVENT;
return EmptyMessageType.TYPE_TO_IGNORE;
}
else
if (stanza.selectSingleNode("//*[local-name()='markable' and namespace-uri()='urn:xmpp:chat-markers:0']")!=null)
Expand Down Expand Up @@ -126,4 +131,4 @@ public static EmptyMessageType getMessageType(Element stanza)

return EmptyMessageType.TYPE_UNKNOWN;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void messageReceived(JID roomJID, JID user, String nickname, Message mess

long bitmask = conversationManager.getSpeficifEmptyMessageArchivingForMUCEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_EVENT && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
if (emptyMessageType!=EmptyMessageType.TYPE_TO_IGNORE && (bitmask & emptyMessageType.getValue()) == emptyMessageType.getValue())
{
ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();

Expand Down

0 comments on commit 7139cd4

Please sign in to comment.