-
Notifications
You must be signed in to change notification settings - Fork 882
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
Implementation of XEP-0313: Message Archive Management (MAM) #76
Conversation
After a quick look: Appears to be missing the provider registration and the entry in https://github.com/igniterealtime/Smack/blob/master/documentation/extensions/index.md |
* Archive Management</a> | ||
* | ||
*/ | ||
public class MamFinProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the following provider look unfinished
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know if that provider was necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Flowdalic I am adding providers implementation. Also I must add new tests so this will take several hours.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, you are not in a race against the time. This will likely take some time to merge. In fact, I would welcome if could also write some integration tests for MAM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Flowdalic I am having some trouble running the integration tests ("gradle integrationTest" command). Seems to display always errors, even when I didn't change anything
@Flowdalic ah sorry. When I implemented xep-308 I didn't change that file (index.md). Should I do it? |
Sure :) |
b2e02be
to
b43b304
Compare
@Flowdalic I added providers implementation + providers tests + MAM description in index.md |
68b2460
to
bc791a1
Compare
|
||
List<Forwarded> messages = new ArrayList<>(resultCollector.getCollectedCount()); | ||
|
||
for (Message resultMessage = resultCollector.pollResult(); resultMessage != null;) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line leads to an endless loop, because only the first message is polled from the queue.
Quick fix:
for (Message resultMessage = resultCollector.pollResult(); resultMessage != null; resultMessage = resultCollector.pollResult()) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steckbrief thanks! :)
The provider registration is still missing: You need to add them to https://github.com/igniterealtime/Smack/blob/master/smack-experimental/src/main/resources/org.jivesoftware.smack.experimental/experimental.providers so that they are registered when Smack initializes itself. White at it, please rename MamPacket to MamElements. I want to fade out the term "Packet" from Smack, as it has no definition in the XMPP world. When done, please squash the commits into one. |
@Flowdalic should i also change the name of the package "org.jivesoftware.smackx.mam.packet" to "org.jivesoftware.smackx.mam.elements"? |
Good initiative and highly appreciated! Which server did you use as a reference to test against? Sometime ago I also made an implementation but not pushed it, while there was no consensus about the version of the XEP and the way the server it had implemented. |
'element' please, so that it is consistent with what is done in the message_correct package. |
@Flowdalic done |
@annovanvliet thanks! :) I am testing it with a MongooseIM server |
@Flowdalic what do you think about those last fixes? ^ |
@Flowdalic I found some bugs here. Fixes coming this week |
@Flowdalic Fixes done. You can continue testing it :) |
return queryArchive(mamQueryIQ, 0); | ||
} | ||
|
||
private void addAdditionalFields(List<AdditionalField> additionalFields, DataForm dataForm) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why this method and the following are not static? Also if you design them null safe, then please go with the if (foo == null) return
approach, do keep the level indentation down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Flowdalic I think that is not necessary to make them static. Those methods were made to refactor the "queryArchive" method.
I didn't understand why the "if (foo == null) return
approach" would be correct. If one of those values is null, I have to continue with the query but without applying that filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You think in the wrong direction. ;) It is not necessary to make them non-static i.e. virtual methods.
Instead of
static void eventuallyDoSomething(Foo foo, Bar bar) {
if (foo != null) {
foo.someting(bar);
}
}
you should write
static void eventuallyDoSomething(Foo foo, Bar bar) {
if (foo == null) return;
foo.something(bar);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I'll do that 👍
I did not finish the review, because I've run out of time for today. So there is likely more to come, but the overall impression is good. For small PRs I'd usually ask people to squash their commits, but since this is a rather larger patch, I'd ask you to add from now on changes on top of 846a (Ideally using |
@Flowdalic Several fixes done. I'll wait the feedback :) |
Hi Flow, Thanks |
More remarks in order of severity:
|
@Flowdalic Thanks for the feedback. I am testing MAM implementation using it on an app connected to a XMPP server. I'll fix those things you found and all the bugs I find while testing, I tell you when that is ready :) |
List<Jid> alwaysJids = null; | ||
List<Jid> neverJids = null; | ||
|
||
boolean done = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the done
boolean as explained above.
e7bebf4
to
642cb6f
Compare
Thanks, please now squash all commits of this branch into one. Note that the branch currently conflicts with An example of a typical git workflow to do this would be:
Now you have to update this PR with that single commit. You would usually set the HEAD of this PRs source branch to that particular commit. |
3f58a3b
to
ac972b9
Compare
Thanks, your current author string looks like this:
Is this what you want, or do you want your full name, e.g.
as this will show up in some places and I feel you may want to take the credits for being the major author. |
Fixes SMACK-625
public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws Exception { | ||
String queryId = parser.getAttributeValue("", "queryid"); | ||
boolean complete = Boolean.parseBoolean(parser.getAttributeValue("", "complete")); | ||
boolean stable = Boolean.parseBoolean(parser.getAttributeValue("", "stable")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful when parsing. stable defaults to true
according to xep313. Should have used ParserUtils.getBooleanAttribute().
I take over from here but will add notes about the things I found while testing your code. |
* @throws InterruptedException | ||
* @throws NotLoggedInException | ||
*/ | ||
public MamPrefsResult updateArchivingPreferences(List<Jid> alwaysJids, List<Jid> neverJids, String defaultField) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultField should have been an enum. Never give the user a chance to use false values.
Assert.assertNull(mamFinIQ.getQueryId()); | ||
|
||
RSMSet rsmSet = mamFinIQ.getRSMSet(); | ||
Assert.assertEquals(rsmSet.getAfter(), "09af3-cc343-b409f"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first argument of assertEquals should always be the expected value.
ANy Reason why I'm getting this error (even though the archives were successfully received?
|
@ojuniour I would need more information about the fin IQ stanza received. |
Thanks for the fast response.. I'm gonna do as you said.. But just a quick question; what version of XMPP-0313 protocol did you implement? I would guess it's between between v0.3, 0.4, 0.4.1 and v0.5? Because I receive an packet first, then data comes after, and finally a to conclude..(mam1 namespace btw). EDIT: This is the link to the FULL details :https://community.igniterealtime.org/message/260514 |
Please do not hijack pull requests when having issues and use the forums instead. Thank you. |
Documentation: http://xmpp.org/extensions/xep-0313.html