-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add PEP nicknames from XEP-0172 #1867
Conversation
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.
👍
Will you also add the possibility to set such a nickname? as FMU now you'd have to use a different client to set it.
==4147910== definitely lost: 1,080 bytes in 15 blocks
where do those lost blocks originate? I'm mostly certain they're not lost in your feature, but still it'd be nice to know. Feel free to attach a logfile.
xmpp_stanza_t* event = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT); | ||
if (event) { | ||
xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(event, STANZA_NAME_ITEMS); | ||
if (items) { | ||
xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, STANZA_NAME_ITEM); | ||
if (item) { | ||
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_name_and_ns(item, STANZA_NAME_NICK, STANZA_NS_NICK); |
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 could be simplified by using xmpp_stanza_get_child_by_path()
xmpp_stanza_t* event = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT); | |
if (event) { | |
xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(event, STANZA_NAME_ITEMS); | |
if (items) { | |
xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, STANZA_NAME_ITEM); | |
if (item) { | |
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_name_and_ns(item, STANZA_NAME_NICK, STANZA_NS_NICK); | |
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_path(stanza, XMPP_STANZA_NAME_IN_NS(STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT), STANZA_NAME_ITEMS, STANZA_NAME_ITEM, XMPP_STANZA_NAME_IN_NS(STANZA_NAME_NICK, STANZA_NS_NICK), 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.
Nah, nick
is NULL this way, and it's non-trivial to debug where exactly does it fail (looks OK to me, huh :/), so I'll probably leave it intact for now.
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.
Indeed, as I forgot that you have to give the full path, i.e. this should work:
xmpp_stanza_t* event = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT); | |
if (event) { | |
xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(event, STANZA_NAME_ITEMS); | |
if (items) { | |
xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, STANZA_NAME_ITEM); | |
if (item) { | |
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_name_and_ns(item, STANZA_NAME_NICK, STANZA_NS_NICK); | |
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_path(stanza, STANZA_NAME_MESSAGE, XMPP_STANZA_NAME_IN_NS(STANZA_NAME_EVENT, STANZA_NS_PUBSUB_EVENT), STANZA_NAME_ITEMS, STANZA_NAME_ITEM, XMPP_STANZA_NAME_IN_NS(STANZA_NAME_NICK, STANZA_NS_NICK), NULL); |
|
97d1925
to
4d6c797
Compare
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.
Thanks for your feature!
Regarding CI:
- Please check https://github.com/profanity-im/profanity/blob/master/CONTRIBUTING.md on how to run clang format.
- You need to add a nickname_pep_subscribe (stub) to the tests. You can grep for avatar_pep_subscribe for example as inspiration
4d6c797
to
761932d
Compare
A couple of questions: How should this play together with
? |
From our MUC:
So I think we need to check if the user did set a nickname for person in their roster and only if they didn't use the nick that we get over this XEP. Same for MUC. Could you add such functionality? And do you plan to also implement the setting of the nick? If you need any help or guidance don't hesitate to ask here or contact us in the MUC. |
From the experience with my transport, users have different expectations. Some indeed prefer to set contact nicknames manually, and are frustrated when they are updated automatically. Other users are rather frustrated when they don't see relevant updates of the nickname (especially if they have saved a nickname provided in a subscription request, which in some clients is equal to setting it manually). I suppose it should be a configuration option then, and the default should be to respect the nickname from the roster first then, as recommended by Modern XMPP.
Maybe, but later. Setting the nickname via PubSub seems to need some server-side support, so I'll need to prepare it for testing first. |
Yes configuration option would be good. Taking roster nick in MUC doesn't make much sense to me since it could be that I want to reply to a user and write "John Tolkien: how are you doing?" because in my roster he is named like that. But everyone else sees his nickname as "JRRT" because that's what he set when joining.
Ok, great. |
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, fix the nesting, add XEP support information to .doap file and disco (XEP-0030, XEP-0115, if it's recommended/required by the XEP that you are adding).
Thank you for your contribution.
if (items) { | ||
xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, STANZA_NAME_ITEM); | ||
if (item) { | ||
xmpp_stanza_t* nick = xmpp_stanza_get_child_by_name_and_ns(item, STANZA_NAME_NICK, STANZA_NS_NICK); |
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.
Even if you want to follow this way, your nesting is too deep. Please, follow the best practices https://testing.googleblog.com/2017/06/code-health-reduce-nesting-reduce.html
@bodqhrohro ping :) |
I see no real-life use for setting the nickname via PubSub and thus not sure what to do and why. I forgot that my transport also sends the nickname in presences, and I implemented PubSub later than that specifically for Gajim as Gajim ignores the nickname in presences and uses only nicknames from PubSub. The person who I made this patch for finally implemented their own patch which takes the nickname from presences, as they found it easier; not sure if they intend to merge it upstream at all. Later I discovered that this actually violates the standard, as it specifies that regular non-subscribe presences MUST NOT include the nick. |
Do I understand you right that you think your PR is obsolete? |
I'm not sure about that, as the other patch violates the XEP, but as of now it Just Works™. PEP is also not a great solution for the task, given that the roster name is anyway the highest priority according to modernxmpp spec, yet it works in Gajim. Slidge implements roster sync via a special privilege, and we probably would go this way eventually too (but that won't work for the users from other servers). As of now, I'll probably close this PR and reopen it later if we come up with some decision. When more important features are implemented, I'll anyway return to the problem of presence flood, as they consume traffic excessively, and those out-of-spec nickname presences are a part of it. |
Feel free to reopen or create a new patch when you feel like it! |
How to test the functionality
I ran valgrind when using my new feature