diff --git a/js/models/conversations.js b/js/models/conversations.js index d7dd07bd..c5cf3b7c 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -35,9 +35,20 @@ }, validate: function(attributes, options) { - var required = ['type', 'timestamp']; - var missing = _.filter(required, function(attr) { return !attributes[attr]; }); - if (missing.length) { return "Conversation must have " + missing; } + var required = ['type', 'timestamp']; + var missing = _.filter(required, function(attr) { return !attributes[attr]; }); + if (missing.length) { return "Conversation must have " + missing; } + + if (this.get('type') === 'private') { + var number = libphonenumber.util.verifyNumber(id); + + this.set({ + id: number, + international_number: libphonenumber.format(number, libphonenumber.PhoneNumberFormat.INTERNATIONAL), + national_number: libphonenumber.format(number, libphonenumber.PhoneNumberFormat.NATIONAL) + }); + + } }, sendMessage: function(body, attachments) {