Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 820028 - If a Facebook contact has several phone numbers only two…

… are imported
  • Loading branch information...
commit 3cbd11e1621a9d4a4c2c00525aa388ad1b722015 1 parent 20f9c39
@jmcanterafonseca authored
View
46 apps/communications/contacts/js/fb/fb_contact_utils.js
@@ -87,6 +87,20 @@ fb.setFriendPictureUrl = function(devContact, url) {
// Adapts data to the mozContact format names
fb.friend2mozContact = function(f) {
+
+ function normalizeFbPhoneNumber(phone) {
+ var out = phone.number;
+ if (phone.country_code && out.indexOf('+') !== 0) {
+ out = '+' + phone.country_code + out;
+ }
+ return out;
+ }
+
+ // Check whether this has been already normalized to mozContact
+ if (Array.isArray(f.familyName)) {
+ return f;
+ }
+
// givenName is put as name but it should be f.first_name
f.familyName = [f.last_name ? f.last_name.trim() : (f.last_name || '')];
var middleName = f.middle_name ? f.middle_name.trim() : (f.middle_name || '');
@@ -111,31 +125,17 @@ fb.friend2mozContact = function(f) {
f.email1 = '';
}
- var nextidx = 0;
- if (f.cell) {
-
- f.tel = [{
- type: [privateType],
- value: f.cell
- }];
-
- nextidx = 1;
- }
-
- if (f.other_phone) {
- if (!f.tel) {
- f.tel = [];
- }
-
- f.tel[nextidx] = {
- type: [privateType],
- value: f.other_phone
- };
-
+ if (Array.isArray(f.phones) && f.phones.length > 0) {
+ f.tel = [];
+ f.phones.forEach(function(aphone) {
+ f.tel.push({
+ type: [privateType],
+ value: normalizeFbPhoneNumber(aphone)
+ });
+ });
}
- delete f.other_phone;
- delete f.cell;
+ delete f.phones;
f.uid = f.uid.toString();
View
2  apps/communications/contacts/js/fb/fb_import.js
@@ -49,7 +49,7 @@ if (typeof fb.importer === 'undefined') {
var FRIENDS_QUERY = [
'SELECT uid, name, first_name, last_name, pic_big, current_location, ' ,
'middle_name, birthday_date, email, profile_update_time, ' ,
- ' work, education, cell, other_phone, hometown_location' ,
+ ' work, education, phones, hometown_location' ,
' FROM user' ,
' WHERE uid ',
'IN (SELECT uid1 FROM friend WHERE uid2=me())' ,
View
2  apps/communications/facebook/js/fb_sync.js
@@ -144,6 +144,8 @@ if (!fb.sync) {
// Updates the FB data from a friend
function updateFbFriend(contactId, cfdata) {
+ fb.friend2mozContact(cfdata);
+
cfdata.fbInfo = cfdata.fbInfo || {};
cfdata.fbInfo.org = [fb.getWorksAt(cfdata)];
View
2  apps/communications/facebook/js/sync_worker.js
@@ -18,7 +18,7 @@ importScripts('/contacts/js/fb/fb_query.js',
var UPDATED_QUERY = [
'SELECT uid, name, first_name, last_name, ' ,
'middle_name, birthday_date, email, current_location, ' ,
- 'work, cell, other_phone, hometown_location, pic_big ' ,
+ 'work, phones, hometown_location, pic_big ' ,
' FROM user' ,
' WHERE uid ',
' IN (SELECT uid1 FROM friend WHERE uid2=me()',
Please sign in to comment.
Something went wrong with that request. Please try again.