Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save messages without body (XEP-0333, XEP-0184, XEP-0085,...) #179

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mightymop
Copy link
Contributor

@mightymop mightymop commented Feb 17, 2021

fix #166
close #130

enable/disable feature:
a1
Output on admin console and pdf:
mam2

@mightymop mightymop changed the title XEP-0333 Rebase to current master XEP-0333 Rebased to current master Feb 17, 2021
@mightymop mightymop mentioned this pull request Feb 17, 2021
@mightymop mightymop force-pushed the xep0333 branch 2 times, most recently from b6a2827 to 7328f04 Compare October 7, 2021 14:09
@mightymop
Copy link
Contributor Author

When will this PR be reviewed / merged?

@mightymop mightymop force-pushed the xep0333 branch 4 times, most recently from a760046 to 28616b1 Compare December 23, 2021 22:05
@mightymop
Copy link
Contributor Author

PR is now up to date with master

@guusdk guusdk force-pushed the xep0333 branch 2 times, most recently from 6201e65 to d579fe5 Compare January 19, 2022 10:30
@guusdk
Copy link
Member

guusdk commented Jan 19, 2022

Rebased to the latest master again, and added a changelog entry.

Copy link
Member

@guusdk guusdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a number of concerns regarding this:

  • the placement of the checkbox on the admin console makes me wonder if the chat marker setting applies to both types of messages (one-on-one and MUC).
  • We might want something similar for other message stanzas that don't have a body (eg: XEP-0184: Message Delivery Receipts, XEP-0085: Chat State Notifications)
  • The code to distill the type of marker from a message seems overly complex. The end result is hardly used.
  • The newly added field org.jivesoftware.openfire.archive.ConversationEvent#marker doesn't seem to be used. Does that mean that this functionality is broken in a cluster?
  • and, somewhat trivial: the MARKERTYPE enum shouldn't have an all-caps name.
  • the second non-null check in if (message.getBody() != null||(message.getBody()==null&&this.conversationManager.isChatmarkerArchivingEnabled())) is unneeded
  • the naming of ConversationEvent.chatmarkerMessageReceived suggests that this is an event handler, but it's not. This duplicates a similarly misnamed, pre-existing org.jivesoftware.openfire.archive.ConversationEvent#chatMessageReceived though.
  • I'm not often one to comment on whitespace, but the (lack of) indentation of the four lines in this if-statement is very confusing:
if (markertype!=ChatMarker.MARKERTYPE.NONE)
{
    eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
    ConversationEvent.chatmarkerMessageReceived(sender, receiver,markertype,
    conversationManager.isMessageArchivingEnabled() ? message.toXML() : null,
    new Date()));
}

My suggestion would be to redesign this functionality, to become something like: "log message stanzas without bodies if it includes metadata for:" (and then offer a checkbox for all types of child elements that we want to support).

@mightymop
Copy link
Contributor Author

yes i have stumbled about an issue in converse js (missing body in retraction message) which would also applies to your concerns... i am going to redesign this PR in the next days :)

@mightymop mightymop force-pushed the xep0333 branch 2 times, most recently from 0386cbc to 57a1f29 Compare January 20, 2022 07:57
@mightymop mightymop changed the title XEP-0333 Rebased to current master Save messages with empty body (XEP-0333, XEP-0184, XEP-0085,...) Jan 20, 2022
@mightymop
Copy link
Contributor Author

Okay i have refactored the whole PR... please review it :)

@mightymop mightymop changed the title Save messages with empty body (XEP-0333, XEP-0184, XEP-0085,...) Save messages without body (XEP-0333, XEP-0184, XEP-0085,...) Jan 20, 2022
@mightymop mightymop requested a review from guusdk January 20, 2022 21:00
@mightymop
Copy link
Contributor Author

I've got a number of concerns regarding this:

  • the placement of the checkbox on the admin console makes me wonder if the chat marker setting applies to both types of messages (one-on-one and MUC).
  • We might want something similar for other message stanzas that don't have a body (eg: XEP-0184: Message Delivery Receipts, XEP-0085: Chat State Notifications)
  • The code to distill the type of marker from a message seems overly complex. The end result is hardly used.
  • The newly added field org.jivesoftware.openfire.archive.ConversationEvent#marker doesn't seem to be used. Does that mean that this functionality is broken in a cluster?
  • and, somewhat trivial: the MARKERTYPE enum shouldn't have an all-caps name.
  • the second non-null check in if (message.getBody() != null||(message.getBody()==null&&this.conversationManager.isChatmarkerArchivingEnabled())) is unneeded
  • the naming of ConversationEvent.chatmarkerMessageReceived suggests that this is an event handler, but it's not. This duplicates a similarly misnamed, pre-existing org.jivesoftware.openfire.archive.ConversationEvent#chatMessageReceived though.
  • I'm not often one to comment on whitespace, but the (lack of) indentation of the four lines in this if-statement is very confusing:
if (markertype!=ChatMarker.MARKERTYPE.NONE)
{
    eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
    ConversationEvent.chatmarkerMessageReceived(sender, receiver,markertype,
    conversationManager.isMessageArchivingEnabled() ? message.toXML() : null,
    new Date()));
}

My suggestion would be to redesign this functionality, to become something like: "log message stanzas without bodies if it includes metadata for:" (and then offer a checkbox for all types of child elements that we want to support).

review plz :)

@Neustradamus
Copy link

@mightymop: One year after your changes, have you received a review from @guusdk?

@mightymop
Copy link
Contributor Author

@mightymop: One year after your changes, have you received a review from @guusdk?

nope

@akrherz akrherz force-pushed the main branch 2 times, most recently from 7c7c5d4 to e6ba183 Compare March 5, 2023 18:01
@guusdk
Copy link
Member

guusdk commented Mar 15, 2023

I have rebased this to the current main branch head.

long bitmask = conversationManager.getSpeficifEmptyMessageArchivingEnabled();

if (emptyMessageType!=EmptyMessageType.TYPE_EVENT && (
emptyMessageType==EmptyMessageType.TYPE_UNKNOWN && ((bitmask & EmptyMessageType.TYPE_UNKNOWN.getValue())==EmptyMessageType.TYPE_UNKNOWN.getValue())||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bitmasking implementation is overly complex (it is hard to reason over). I don't think it is doing what it intends to do: the emptyMessageType of the stanza is compared with just one bitmask value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complex code is duplicated in four places. That will make maintaining this code more difficult.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed and refactored this.

guusdk added 4 commits March 15, 2023 16:17
Using the default SAXReader can be dangerous, if certain properties aren't set. Using a new instance for each stanza that is processed probably requires more resources than is needed. Both issues can be prevented by using `org.jivesoftware.util.SAXReaderUtil`
@guusdk guusdk self-requested a review March 15, 2023 15:47
@guusdk
Copy link
Member

guusdk commented Mar 15, 2023

I identified at least one bug, and several inconsistencies. I've committed a number of changes that each address some concerns that I had. The current state of the code is untested. I particularly worry how this behaves in a cluster.

Additional thought: maybe we should support for XEP-0334: Message Processing Hints. Server-side rules are generally good, but they aren't discoverable and may lag behind. If a new XEP is written tomorrow and we do/don't want that in MAM, hints can help with that. On the other hand, I'm wondering if having some clients having their empty-bodied messages stored in MAM, is introducing more confusion than having either all or none of them do that. That probably only applies to MUC archives though.

@guusdk
Copy link
Member

guusdk commented Mar 15, 2023

I'm now noticing more code duplication, in the sense that most of the configuration is duplicated for MUC vs. non-MUC messages. That also makes me wonder if my previous refactoring has taken that into account correctly.

In all, I'm disliking the over-complication of this solution: both in the implementation, as well as the UI options that are presented to the end-user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chatmarkers are not saved to Archive!
4 participants