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

Nice UI for adding a contact through a Gateway #1176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

singpolyma
Copy link
Contributor

Uses jabber:iq:gateway where supported (such as slidge and cheogram) and
otherwise falls back to jid escaping where supported, or finally traditional %
escaping. When searching for contacts, automatically search all gateways that
are added to contacts as well, and show any relevant results.

Note: if the gateway returns an error because the format is bad, this doesn't
show the error since that doesn't really fit the search paradigm, and instead it
simply does not show a result for that gateway.

Also contains a patch to show sms contacts with the "mobile" icon and gateways themselves with the "bot" icon.

@singpolyma singpolyma changed the title Nice UI for adding a contact through a Gatewa Nice UI for adding a contact through a Gateway Mar 18, 2023
@edhelas
Copy link
Member

edhelas commented Mar 18, 2023

Thanks for the PR ! I'll try to review it in the upcoming days and give you feedback :)

Copy link
Member

@edhelas edhelas left a comment

Choose a reason for hiding this comment

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

Is there a way for me to properly test it ?

@@ -32,8 +32,7 @@ public function roster()

public function capability()
{
return $this->hasOne('App\Info', 'node', 'node')
->whereNull('server');
Copy link
Member

Choose a reason for hiding this comment

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

This is risky, I'll have to double check if it doesn't bring some side issues

app/Info.php Outdated Show resolved Hide resolved
}

public function foundJid($prompt, $jid) {
$session = \Movim\Session::start();
Copy link
Member

Choose a reason for hiding this comment

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

Not a big fan of using memory session for that, I'd prefer to have just parameters passed around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to store state somewhere, since this data comes in asynchronously from XMPP and there can be more than one. The search results are rendered using draw and expect the entire list of results to be available for that. Additionally, we do probably want to cache this for a short time since it's a remote lookup.

I'm not saying memory session is definitely right for it, but I'm curious what you would suggest as an alternative here in order to have prepareSearch know about all the items that have come in asynchronously?

app/widgets/Search/Search.php Outdated Show resolved Hide resolved
->request();
} else if ($contact->presence->capability->getGatewayTypeAttribute()) {
if ($contact->presence->capability->hasFeature("jid\\20escaping")) {
$this->foundJid($key, Utils::escapeJidLocalpart($key).'@'.$contact->presence->jid);
Copy link
Member

Choose a reason for hiding this comment

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

Rebuilding the JID this way seems risky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not "rebuilding" but rather building a new JID out of the query and the gateway, having already determined in the line before that this escaping format is supported by the gateway.

We could put the operation in a method somewhere, but it's always going to do fundamentally what this line does.

Uses jabber:iq:gateway where supported (such as slidge and cheogram) and
otherwise falls back to jid escaping where supported, or finally traditional %
escaping.  When searching for contacts, automatically search all gateways that
are added to contacts as well, and show any relevant results.

Note: if the gateway returns an error because the format is bad, this doesn't
show the error since that doesn't really fit the search paradigm, and instead it
simply does not show a result for that gateway.
@Neustradamus
Copy link
Contributor

@edhelas: Have you seen @singpolyma changes?

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

Successfully merging this pull request may close these issues.

None yet

3 participants