[Davical-general] Format of the tel field in addressbook_address_tel

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Davical-general] Format of the tel field in addressbook_address_tel

Matthias Heinz
Hi,

while I was integrating asterisk with davical, I found something very
interesting in the database. In addressbook_address_tel there're the
fields tel and property. The tel field contains just the phone number,
whilst the property field contains the type and the number of the entry
(I guess that is what you can see when accessing the entry over carddav.
I haven't changed any values, so I'm not sure...)

The reason, why I took such a close look at the database is, that I'm
doing a reverse lookup of telephone numbers and therefore I need the
numbers in a very clean way (because doing regexp on a database is kinda
hard and doing multiple look-ups to get the name for a number is very
expensive).

Now, If you've got something like TEL;TYPE=work:+49 (6047) 986521 in the
property field, then the tel field looks like: +49 (6047) 986521

But, if your property field looks like TEL;TYPE=work:+496047986521, then
the tel field is stripped of the + and you just get 496047986521.

Now I'm wondering what is happening here and If I can make use of it.

In my asterisk dial plan, I get the phone number without spaces, slashes
or brackets, so I need a field in the database to match against. I could
store all numbers as e.g. +496047986521 in the address book, but this is
hard to read for a human. It's much easier to look at +49 (6047) 986521.

So, my questions are:
Why is the + stripped, if you enter the number without spaces, slashes,
etc? Is this a bug or intended?

Is the tel field used for something important or can I add some code
(and send in a patch) that strips slashes, dashes, spaces, brackets, ...
from this field?
I guess there could be a problem with sip addresses, but - I'm not sure
about this - I think a sip address must not have a + at the beginning,
so this could be used to differ between normal numbers and them.


Best regards
Matthias


--
Matthias Heinz
Uwe Schneider GmbH
Heegwaldring 12
63694 Limeshain
Tel.: +49 / 6047 / 98 65 21
FAX.: +49 / 6047 / 98 73 96
E-Mail: [hidden email]

Uwe Schneider Gesellschaft für innovative
Produkte der Computertechnik mbH
Sitz der Gesellschaft: Limeshain
Registergericht: Friedberg HRB 5895
Geschäftsführer: Uwe Schneider

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Davical-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/davical-general
Reply | Threaded
Open this post in threaded view
|

Re: Format of the tel field in addressbook_address_tel

Ján Máté-2
Hi,

On Nov 9, 2012, at 5:10 PM, Matthias Heinz <[hidden email]> wrote:

> Hi,
>
> while I was integrating asterisk with davical, I found something very
> interesting in the database. In addressbook_address_tel there're the
> fields tel and property. The tel field contains just the phone number,
> whilst the property field contains the type and the number of the entry
> (I guess that is what you can see when accessing the entry over carddav.
> I haven't changed any values, so I'm not sure...)
>
> The reason, why I took such a close look at the database is, that I'm
> doing a reverse lookup of telephone numbers and therefore I need the
> numbers in a very clean way (because doing regexp on a database is kinda
> hard and doing multiple look-ups to get the name for a number is very
> expensive).
use of regex in PostgreSQL is very easy, for example:

SELECT caldav_data, regexp_replace(unnest(regexp_matches(caldav_data, E'^(?:[a-z0-9-]+\.)?TEL.*:([^:]*)\r$', 'gni')), '[^+0-9]', '', 'g') FROM caldav_data WHERE caldav_type='VCARD';

=> you will get an output in the following format:
VCARD phone_number (with removed all non-numerical characters except the '+')


> Now, If you've got something like TEL;TYPE=work:+49 (6047) 986521 in the
> property field, then the tel field looks like: +49 (6047) 986521
>
> But, if your property field looks like TEL;TYPE=work:+496047986521, then
> the tel field is stripped of the + and you just get 496047986521.
>
> Now I'm wondering what is happening here and If I can make use of it.
>
> In my asterisk dial plan, I get the phone number without spaces, slashes
> or brackets, so I need a field in the database to match against. I could
> store all numbers as e.g. +496047986521 in the address book, but this is
> hard to read for a human. It's much easier to look at +49 (6047) 986521.
>
> So, my questions are:
> Why is the + stripped, if you enter the number without spaces, slashes,
> etc? Is this a bug or intended?
very probably a bug

>
> Is the tel field used for something important or can I add some code
> (and send in a patch) that strips slashes, dashes, spaces, brackets, ...
> from this field?

I don't know if it is currently used, but if it is (or will be) it should contain
the REAL value from the vCard so you cannot change to something else.


JM



> I guess there could be a problem with sip addresses, but - I'm not sure
> about this - I think a sip address must not have a + at the beginning,
> so this could be used to differ between normal numbers and them.
>
>
> Best regards
> Matthias
>
>
> --
> Matthias Heinz
> Uwe Schneider GmbH
> Heegwaldring 12
> 63694 Limeshain
> Tel.: +49 / 6047 / 98 65 21
> FAX.: +49 / 6047 / 98 73 96
> E-Mail: [hidden email]
>
> Uwe Schneider Gesellschaft für innovative
> Produkte der Computertechnik mbH
> Sitz der Gesellschaft: Limeshain
> Registergericht: Friedberg HRB 5895
> Geschäftsführer: Uwe Schneider
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_nov
> _______________________________________________
> Davical-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/davical-general

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Davical-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/davical-general

smime.p7s (6K) Download Attachment