"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "js/modules/types/contact.js" between
Signal-Desktop-1.35.2.tar.gz and Signal-Desktop-1.36.1.tar.gz

About: Signal-Desktop is a cross-platform encrypted messaging service (also available for mobile devices).

contact.js  (Signal-Desktop-1.35.2):contact.js  (Signal-Desktop-1.36.1)
skipping to change at line 20 skipping to change at line 20
SignalService.DataMessage.Contact.PostalAddress.Type.HOME; SignalService.DataMessage.Contact.PostalAddress.Type.HOME;
exports.parseAndWriteAvatar = upgradeAttachment => async ( exports.parseAndWriteAvatar = upgradeAttachment => async (
contact, contact,
context = {} context = {}
) => { ) => {
const { message, regionCode, logger } = context; const { message, regionCode, logger } = context;
const { avatar } = contact; const { avatar } = contact;
// This is to ensure that an omit() call doesn't pull in prototype props/metho ds // This is to ensure that an omit() call doesn't pull in prototype props/metho ds
const contactShallowCopy = Object.assign({}, contact); const contactShallowCopy = { ...contact };
const contactWithUpdatedAvatar = const contactWithUpdatedAvatar =
avatar && avatar.avatar avatar && avatar.avatar
? Object.assign({}, contactShallowCopy, { ? {
avatar: Object.assign({}, avatar, { ...contactShallowCopy,
avatar: {
...avatar,
avatar: await upgradeAttachment(avatar.avatar, context), avatar: await upgradeAttachment(avatar.avatar, context),
}), },
}) }
: omit(contactShallowCopy, ['avatar']); : omit(contactShallowCopy, ['avatar']);
// eliminates empty numbers, emails, and addresses; adds type if not provided // eliminates empty numbers, emails, and addresses; adds type if not provided
const parsedContact = parseContact(contactWithUpdatedAvatar, { regionCode }); const parsedContact = parseContact(contactWithUpdatedAvatar, { regionCode });
const error = exports._validate(parsedContact, { const error = exports._validate(parsedContact, {
messageId: idForLogging(message), messageId: idForLogging(message),
}); });
if (error) { if (error) {
logger.error( logger.error(
skipping to change at line 53 skipping to change at line 55
return parsedContact; return parsedContact;
}; };
function parseContact(contact, options = {}) { function parseContact(contact, options = {}) {
const { regionCode } = options; const { regionCode } = options;
const boundParsePhone = phoneNumber => const boundParsePhone = phoneNumber =>
parsePhoneItem(phoneNumber, { regionCode }); parsePhoneItem(phoneNumber, { regionCode });
return Object.assign( return {
{}, ...omit(contact, ['avatar', 'number', 'email', 'address']),
omit(contact, ['avatar', 'number', 'email', 'address']), ...parseAvatar(contact.avatar),
parseAvatar(contact.avatar), ...createArrayKey('number', compact(map(contact.number, boundParsePhone))),
createArrayKey('number', compact(map(contact.number, boundParsePhone))), ...createArrayKey('email', compact(map(contact.email, parseEmailItem))),
createArrayKey('email', compact(map(contact.email, parseEmailItem))), ...createArrayKey('address', compact(map(contact.address, parseAddress))),
createArrayKey('address', compact(map(contact.address, parseAddress))) };
);
} }
function idForLogging(message) { function idForLogging(message) {
return `${message.source}.${message.sourceDevice} ${message.sent_at}`; return `${message.source}.${message.sourceDevice} ${message.sent_at}`;
} }
exports._validate = (contact, options = {}) => { exports._validate = (contact, options = {}) => {
const { messageId } = options; const { messageId } = options;
const { name, number, email, address, organization } = contact; const { name, number, email, address, organization } = contact;
skipping to change at line 97 skipping to change at line 98
return null; return null;
}; };
function parsePhoneItem(item, options = {}) { function parsePhoneItem(item, options = {}) {
const { regionCode } = options; const { regionCode } = options;
if (!item.value) { if (!item.value) {
return null; return null;
} }
return Object.assign({}, item, { return {
...item,
type: item.type || DEFAULT_PHONE_TYPE, type: item.type || DEFAULT_PHONE_TYPE,
value: parsePhoneNumber(item.value, { regionCode }), value: parsePhoneNumber(item.value, { regionCode }),
}); };
} }
function parseEmailItem(item) { function parseEmailItem(item) {
if (!item.value) { if (!item.value) {
return null; return null;
} }
return Object.assign({}, item, { return { ...item, type: item.type || DEFAULT_EMAIL_TYPE };
type: item.type || DEFAULT_EMAIL_TYPE,
});
} }
function parseAddress(address) { function parseAddress(address) {
if (!address) { if (!address) {
return null; return null;
} }
if ( if (
!address.street && !address.street &&
!address.pobox && !address.pobox &&
!address.neighborhood && !address.neighborhood &&
!address.city && !address.city &&
!address.region && !address.region &&
!address.postcode && !address.postcode &&
!address.country !address.country
) { ) {
return null; return null;
} }
return Object.assign({}, address, { return { ...address, type: address.type || DEFAULT_ADDRESS_TYPE };
type: address.type || DEFAULT_ADDRESS_TYPE,
});
} }
function parseAvatar(avatar) { function parseAvatar(avatar) {
if (!avatar) { if (!avatar) {
return null; return null;
} }
return { return {
avatar: Object.assign({}, avatar, { avatar: { ...avatar, isProfile: avatar.isProfile || false },
isProfile: avatar.isProfile || false,
}),
}; };
} }
function createArrayKey(key, array) { function createArrayKey(key, array) {
if (!array || !array.length) { if (!array || !array.length) {
return null; return null;
} }
return { return {
[key]: array, [key]: array,
 End of changes. 9 change blocks. 
24 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)