FOOD FOR THOUGHT One Address Book To Rule Them All?

luckman212

Guru
Joined
Jul 7, 2010
Messages
272
Reaction score
0
Hi everyone,

I've been searching High and Low for weeks now but coming up empty. Hoping someone else has crossed this bridge before and has some advice.

The problem I'm trying to solve is having a Single, Unified, Self-hosted Address Book source that syncs between my desktop computer (a Mac), my iPhone (via CardDAV) and my Desk phone (PIAF).

So far I'm using the CardDAV package for my Synology and syncing to that with my Mac + iPhone. Great. But I was wanting to be able to have CALLERID lookups somehow query that source as well. Has anyone found a way to query a CardDAV server from the dialplan? Or maybe a script that I can set up as a periodic cron job to dump out all the names + numbers from the CardDAV server to a mysql db and query that?
 

wa4zlw

Member
Joined
Feb 14, 2008
Messages
845
Reaction score
22
I dont have an answer but I have a synology NAS at home and this might be a good solution. How have you setup things?

Leon
 
Joined
Nov 19, 2007
Messages
180
Reaction score
8
This would be great! I have a similar setup that syncs my contacts to all my devices/PCs/etc. It also supports CardDAV. I don't know how quick real-time lookups would be, but I could see a setup where a background process uses CardDAV to periodically sync to the asterisk phonebook or some other source that Asterisk can already use.
 

luckman212

Guru
Joined
Jul 7, 2010
Messages
272
Reaction score
0
I'm not doing anything too fancy (yet). Just installed the built-in CardDAV package from the Synology Package Manager. It uses a PostgreSQL db as its backend. So this can be queried directly from the commandline when you're logged in as root.

Some stuff I have "figured out" so far (this is not a complete solution, just the seed of an idea)

Get a FULL NAME (FN) direct from the pgsql db given a number in XXX-YYY-ZZZZ format:
psql -U postgres -d caldav -c "select vcard_text from addressbook_object where vcard_text like '%XXX%YYY%ZZZZ%' LIMIT 1" -A | grep -o 'FN:.*$' | cut -c 4-

Get a list of sanitized TEL: numbers for a single contact given the contact's resource_id
psql -U postgres -d caldav -c "select vcard_text from addressbook_object where resource_id = 329" -A | grep '^TEL;' | grep -o ':.*$' | tr -d ' \-\(\):'

Dump a list of resource_id's
psql -U postgres -d caldav -c "SELECT resource_id FROM addressbook_object WHERE kind = '0' ORDER BY resource_id;"

I think that running these queries "ad-hoc" from inside the dialplan is probably not a good idea for a production system. My idea is along these lines:

on a schedule (cron):
dump out resource_id,vcard_text to a MySQL db
grep out just the TEL: entries
strip all spaces, dashes etc
store sanitized NUM and NAME in a new MySQL db or separate table
query this (should be fast) using built in CID functions straight from the dialplan....
 

Members online

Forum statistics

Threads
25,782
Messages
167,509
Members
19,203
Latest member
frapu
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top