-
Sam
I decided to take another stab at implementing multi-item results on XEP-0004: Data Forms, but as usual I'm still confused. The spec makes it look like items and repoted can exist alongside field, title, etc. but what does it even mean to have a normal form that also contains reported/items? Is this correct that a form can have both normal fields and the multi-item stuff?
-
Zash
The spec does not forbid it, so it is allowed. Glob help us all.
-
Sam
The schema seems to suggest it's allowed (though as usual, I don't know XML schema and may be mis-reading something), but the meaning of the actual text seems very unclear to me
-
Sam
I guess a better question is "is anyone else doing or allowing this?"
-
Sam
aioxmpp seems to disallow fields being mixed in with items, but it looks like it would allow title/instructions as far as I can see
-
Zash
Someone asked about this recently, either here or xsf@, trying to find it.
-
Sam
Might have been me; I think I tried to do this a couple of months ago but I can't remember what was said
-
Sam
nbxmpp (Gajim) appears to allow title and instructions but disallow fields too; I guess I'll just do this since that's what others are doing (though if anyone has an example of doing something else, I'd love to know)
-
Sam
Although this seems entirely unsupported by the text or schema.
-
Zash
Aha, found https://logs.xmpp.org/xsf/2022-06-07?p=h#2022-06-07-50bc9a07d99ec16a
-
Sam
oh nice, thanks
-
Sam
drat; singpolyma makes a good argument for why both make sense, now I'm not sure what to do.
-
Zash
https://logs.xmpp.org/xsf/2022-06-08?p=h#2022-06-08-7b362a17b6eba8a8 hints at prior art of allowing both (or not disallowing)
-
Zash
I note that Prosody's util.dataforms doesn't do <reported> at all
-
Zash
There's a user search module doing it, but it's constructing the XML itself IIRC
-
lovetox
Sam, i never came across a use case where this is needed
-
lovetox
and i dont implement stuff that "maybe, in theory someone at someday could need"
-
lovetox
especially if it is not described as a clear use case for the xep
-
lovetox
and only is possible because nothing forbids it
-
Sam
singpolymas example is a pretty concrete one though (in jmp.chat they want to show the account balance followed by a table of recent transactions)
-
Sam
Sounds like there are already some incompatibilities due to the ambiguity in the spec, so maybe I should just not implement it at all.
-
lovetox
you know you cannot have only one dataform in a stanza
-
Sam
That normally means "this form or this other fallback form" in most specs though, not "display both these forms"
-
Sam
(to be clear, it sounded like you were saying "you must have multiple forms", but obviously that's not right, so I'm assuming you meant "it's possible to have multiple forms"?)
-
lovetox
yes its possible, depends on where you use that
-
Sam
Sure, so now if I include a normal form and a multi-item form we have an ambiguity about what that means that may depend on context, so I dunno if that approach is better
-
lovetox
are we talking about adhoc results?
-
Sam
Could be anything, this is just a generic library for building forms to be embedded in other things (ad-hoc is one of the things that already uses it)
-
lovetox
funny, the adhoc spec misses the FORM_TYPE in all its dataforms
-
lovetox
and i never heard of "fallback" forms
-
lovetox
either you support dataforms or not
-
lovetox
the adhoc spec does not say anything about multiple forms
-
Sam
I'd have to go look, but I'm pretty sure several specs define having multiple forms in one payload as "if you don't support something in the first form, use the second"
-
Sam
or "show the title and let the user choose between these two forms" or something along thos elines
-
lovetox
i think you misremember, you probably mean IBR
-
lovetox
which has a Dataform, and if you dont support a dataform, here are custom xep defined fileds as fallback
-
Sam
Could be, but either way it sounds like the meaning of multiple forms is also not well defined or is very context dependent, which still makes it hard to implement data forms cleanly
-
lovetox
there is no fallback for "i implemented only half of the dataform xep"
-
lovetox
but this would not have anything to do with your lib or?
-
lovetox
you just parse a dataform
-
lovetox
if its 2, then you parse 2
-
Zash
You don't strictly need FORM_TYPE to render a random form, no?
-
lovetox
its client business if he displays 2 or 1
-
lovetox
Zash, the problem xmpp should be extensible
-
lovetox
if the form does not define that its indeed the form from the xep
-
lovetox
i cannot filter the forms for the correct formtype
-
lovetox
means, if someone attaches a second form, i dont know which one to choose
-
lovetox
its like if you add a new custom node, without namespace
-
lovetox
yes its possible , but not really good design
-
lovetox
to the use case with the account balance, if someone adds a issue in Gajim requesting that i display multiple forms below each other on adhoc results
-
lovetox
i would implement that
-
lovetox
thats like 5 minutes of work
-
Sam
Even if we assume this is all a thing we could do that would work for every spec, it's still unclear to me whether multi-item forms should include title/instructions. It makes sense that they would, I just think we need some clarity here
-
lovetox
im didnt read the spec for that, but it seems like a nobrainer
-
lovetox
like here have a form, but i dont tell you what it is about
-
lovetox
does not seems like a good solution
-
lovetox
you could argue, its probably in the context of how you requested this clear
-
Sam
I don't disagree, but if we say "no fields, but can have instructions" we're just inventing stuff that the spec definitely doesn't say, so that seems like it will cause incompatibilities and problems.
-
lovetox
yes this should be clarified
-
lovetox
reading the XEP now though nothing idicates that this is not to be expected
-
lovetox
title and instructions are described
-
lovetox
and later there is one paragraph, about how a table can be displayed in a form
-
Sam
Right, but if title and instructions are allowed then why wouldn't fields be?
-
lovetox
yes, i agree, its not forbidden
-
Sam
But multiple libraries seem to forbid it, so I'm not sure what to do to avoid bad incompatibilities.
-
lovetox
it would though then really messy in my opinion
-
lovetox
like then the order really matters
-
lovetox
like what if reported comes in the middle of the fields etc
-
lovetox
like its clear that nobody had this use case in mind
-
Sam
Yah
-
lovetox
any sane dev would wrap this in some parent nodes
-
lovetox
and separate the forms
-
Sam
I'm not sure that's true
-
Sam
I suppose I need to know what clients are doing in real life. Eg. if most clients would just ignore the second form, now half the data you returned isn't being displayed. Doesn't seem like a good idea in that case.
-
lovetox
there is no way clients support this one way or another
-
lovetox
its just not a use case until now maybe
-
lovetox
and now we can decide which way to go
-
Sam
yah, maybe it's impossible to ensure good compatibility so we should just pick something, fix the XEP (or write a new XEP that clarifies it) and move on
-
lovetox
or do nothing, having one use case in decades of usage
-
lovetox
its just not supported in xmpp ..
-
Sam
Maybe, but that still leaves me with "I have to implement this, different clients implement it in different ways and I'm not sure which one I should do"
-
lovetox
i doubt this, you have one example where a lib parses both, reported and normal fields into one object?
-
Sam
Apparently Smack allows mixing them, but nbxmpp does not. Which is right? The current state of the world is fine only until some dev sends a mixed form from smack to nbxmpp and now they can't figure out why their thing is broken.
-
lovetox
smacks allows to parse it mixed?
-
lovetox
or smacks allows to create mixed forms?
-
Sam
Apparently; that's what someone said earlier
-
Sam
Both, I think? Let me try to figure it out, one moment
-
lovetox
because thats two very different things
-
Sam
Actually, I don't see multi-item forms in Smack at all, so maybe they were wrong
-
Sam
oh wait, there it is, looking again
-
Sam
Yah, looks like it allows both. It parses using the same dataform builder that you'd use to create your own, and it allows adding fields and items
-
lovetox
and then how does it make it accessable by the client?
-
Sam
You can call a method to get fields, you can call another method to get items
-
lovetox
.......
-
lovetox
damn it
-
lovetox
:D
-
Sam
Looks like it loses ordering info between the two; they're kept ordered, but separate
-
lovetox
yeah i guess then you have to decide :)
-
lovetox
of course its not easily doable, you would need to put extra thought into that
-
lovetox
but i guess its always, fields first
-
lovetox
items later
-
lovetox
atleast i cant think of a reason why i would display a Table first in GUI, and afterwards some info
-
lovetox
either way its probably not critical here
-
Sam
If I were to support both I think from my APIs perspective I would treat items as if they were just another field that takes multiple values (and the value is other fields).
-
Sam
Items are displayed like columns. If there's a field then more items, then they're just two separate tables with the same header.
-
lovetox
if i would implement that, i would make something like dataform.add_table()
-
lovetox
table.add_row()
-
Sam
yah, something like that
-
Sam
I'll write up all the possibilities from this discussion and send it to standards@. Maybe then we can come to a consensus and I can write an XEP clarifying this, however it comes out.
-
lovetox
i mean if i think about it, and we say, ok that was intended, dataforms support putting both in, its not terrible hard to update the dataform implementations
-
Sam
Email describing some of this sent to standards@, please mention anything I've left out or if you think I've mischaracterized anything.