InnovateAsterisk / Browser-Phone

A fully featured browser based WebRTC SIP phone for Asterisk
https://www.innovateasterisk.com
GNU Affero General Public License v3.0
505 stars 246 forks source link

conditionally provision buddy image data #379

Open vieridipaola opened 1 year ago

vieridipaola commented 1 year ago

Hi,

For all those buddies (maybe even xmpp -- not sure yet) that do not have an image/avatar already set (as in manually when creating with the UI), I'd like to automatically provide an image.

I was thinking of setting a timer with window.setInterval that would periodically scan the buddy list in search of buddies without an image or with a default image. Or maybe once from web_hook_on_init, and then every time a new buddy is created (maybe web_hook_on_invite or some other on_create hook).

I can look up for each buddyObj.ExtNo an image and get a URL for it (http://domain.org/images/1234.png).

How can I check to see if the image data is already set or not? Should I look that up in local storage?

How can I get the image data from a URL and store it where? To local storage? Should I be doing something like what's in function EditBuddyWindow?

How would you handle it if you wanted to provision avatar image data? Any suggestions before I try to dig in?

InnovateAsterisk commented 1 year ago

Personally, I feel buddy management should only be done via XMPP. This allows each user to manage their own profile, picture, and visible information.

(I also wish there was something better than XMPP. I find it quite old-school, and lacking in many features.)

vieridipaola commented 1 year ago

I also wish there was something better than XMPP

I just stumbled on JAMI/JAMS (https://jami.net and https://jami.biz/jams-user-guide). It looks like it supports "messaging". I'm not sure yet, but I think it might be used to connect to Asterisk too (not just allow peer-to-peer communication).

InnovateAsterisk commented 1 year ago

I was thinking more along the lines of: https://signal.org/

it’s what WhatsApp use.

vieridipaola commented 1 year ago

Sure, Signal, very popular. However, have you tried installing the server? A couple of years ago I tried to get some documentation on that, and it was really confusing. Certainly not as straightforward and tried out as installing a jabber server. However, things may have changed nowadays.

vieridipaola commented 1 year ago

This allows each user to manage their own profile, picture, and visible information.

Well, in a large organization it makes sense (at least to me) to auto-provision the user's or extension's picture. That's because in a work environment most people don't have time or don't care to set their custo avatars. However, a company or institution often has most of its users' photos on file. Besides, this information is already there in our case because each time a user logs into the intranet his /her picture is displayed. The idea is to take advantage of this information and pass it on to Browser Phone.

I'm currently overriding the buddy avatars when displaying them in the buddy list. I do so by customizing function UpdateBuddyList like so for "extension", "contact" and even "xmpp":

html += "<div id=\"contact-"+ buddyObj.identity +"-picture\" class=buddyIcon style=\"background-image: url('https://intranet.domain.org/services/whoami/cgi-bin/getExtenPic.php?exten=" + buddyObj.ExtNo + "')\"></div>";

Ideally, I'd like to provision the picture that's on file UNLESS the user sets his/her own picture...

I'd like to do the same for the background image when an incoming call is ringing.

UPDATE: for the latter I do something like this for now:

function AddLineHtml(lineObj, direction){
    var avatar = getPicture(lineObj.BuddyObj.identity);
// Custom picture override:
    avatar = "https://intranet.domain.org/services/whoami/cgi-bin/getExtenPic.php?exten=" + lineObj.BuddyObj.ExtNo;
InnovateAsterisk commented 1 year ago

Try this; when you make a new user set them up as xmpp, and create their vCard in the xmpp server already. You should already have access to all this, so this shouldn’t be a problem. Find the vCard table and add the data preemptively. You can include the profile picture in the vCard data.

Then when they first log into the browser phones, their data is already provisioned. (They could even have a small roster too).

vieridipaola commented 1 year ago

The problem is that not all of the endpoints I'd like to provision the pictures for are "xmpp buddies". Some are simply "contacts" - even internally. For instance, some users only have DECTs (no SIP, just plain DECTs) because they move around a lot. However, their DECT numbers are strictly associated to them, so the image URL I mentioned above gets that info (eg. DECT number -> user pic). I could create the xmpp account for the DECT numbers -- sure. However, I'd also have to provision these DECT numbers as buddies to all the Browser Phone users which is not necessarily required or wanted.

There's an even more complex situation where some users have BYODs or a company cell phone which they use to call internally too almost as if they were DECTs. These "long numbers" are also in the database, and the above-mentioned URL retrieves their user pics. I don't think I'm going to create xmpp accounts and vcards for these.

Maybe all I need is a custom web hook for getPicture()?

InnovateAsterisk commented 1 year ago

So this is why I’m not entirely happy with xmpp, it doesn’t seem to have the concept of “just an arbitrary contact”, it always had to be a mutual buddy of another person. I’m thinking of a way to have buddy management off a separate service, maybe a proxy to the xmpp service that can mix in arbitrary contact information. (This would also be so that the same contacts will appear in other devices)