@dhyasama/totem-models 6.21.2 → 6.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +14 -0
- package/lib/Note.js +4 -0
- package/lib/Organization.js +15 -30
- package/lib/Person.js +14 -28
- package/package-lock.json +1829 -0
- package/package.json +3 -3
- package/test/Organization.js +66 -0
- package/test/Person.js +87 -1
package/.npmignore
ADDED
package/lib/Note.js
CHANGED
|
@@ -44,6 +44,10 @@ module.exports = function(mongoose, config) {
|
|
|
44
44
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// Note.statics.getByCreator = function(personId, cb) {
|
|
48
|
+
// this.find({ 'createdBy': personId }).exec(cb);
|
|
49
|
+
// };
|
|
50
|
+
|
|
47
51
|
Note.statics.getById = function(id, cb) {
|
|
48
52
|
this.findOne({
|
|
49
53
|
'_id': id,
|
package/lib/Organization.js
CHANGED
|
@@ -922,7 +922,7 @@ module.exports = function(mongoose, config) {
|
|
|
922
922
|
|
|
923
923
|
Organization.methods.merge = function(id) {
|
|
924
924
|
if (this.merged.indexOf(id) == -1) {
|
|
925
|
-
this.merged.
|
|
925
|
+
this.merged = this.merged.concat([id]);
|
|
926
926
|
return true;
|
|
927
927
|
}
|
|
928
928
|
else {
|
|
@@ -1306,48 +1306,33 @@ module.exports = function(mongoose, config) {
|
|
|
1306
1306
|
var getUsername = function getUsername(val) {
|
|
1307
1307
|
|
|
1308
1308
|
var URL = require('url');
|
|
1309
|
-
var
|
|
1309
|
+
var parsedUrl = URL.parse(val);
|
|
1310
|
+
var protocol = parsedUrl.protocol;
|
|
1310
1311
|
|
|
1311
|
-
|
|
1312
|
+
if (!protocol) { parsedUrl = URL.parse('http://' + val); }
|
|
1312
1313
|
|
|
1313
|
-
|
|
1314
|
-
if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
|
|
1315
|
-
if (result.indexOf('organization/') === 0) { result = result.replace('organization/', ''); }
|
|
1316
|
-
if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
|
|
1314
|
+
var pathname = parsedUrl.pathname;
|
|
1317
1315
|
|
|
1318
|
-
|
|
1316
|
+
if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
|
|
1317
|
+
if (pathname.indexOf('company/') === 0) { pathname = pathname.replace('company/', ''); }
|
|
1318
|
+
if (pathname.indexOf('organization/') === 0) { pathname = pathname.replace('organization/', ''); }
|
|
1319
|
+
if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
|
|
1319
1320
|
|
|
1320
|
-
|
|
1321
|
+
console.log('Username:', val, '-->', pathname);
|
|
1321
1322
|
|
|
1322
|
-
|
|
1323
|
+
return pathname;
|
|
1323
1324
|
|
|
1324
|
-
var domains = {
|
|
1325
|
-
facebook: 'https://facebook.com',
|
|
1326
|
-
linkedin: 'https://linkedin.com/company',
|
|
1327
|
-
twitter: 'https://twitter.com',
|
|
1328
|
-
crunchbase: 'https://crunchbase.com/organization'
|
|
1329
1325
|
};
|
|
1330
1326
|
|
|
1331
1327
|
var username = getUsername(value);
|
|
1332
1328
|
|
|
1333
|
-
// todo - tests
|
|
1334
|
-
// getUsername('dhyasama');
|
|
1335
|
-
// getUsername('in/dhyasama');
|
|
1336
|
-
// getUsername('http://facebook.com/dhyasama');
|
|
1337
|
-
// getUsername('http://linkedin.com/in/dhyasama');
|
|
1338
|
-
// getUsername('https://twitter.com/dhyasama');
|
|
1339
|
-
// getUsername('http://www.facebook.com/dhyasama');
|
|
1340
|
-
// getUsername('http://www.linkedin.com/dhyasama/');
|
|
1341
|
-
// getUsername('http://www.twitter.com/dhyasama?hello=world');
|
|
1342
|
-
// getUsername('http://www.facebook.com');
|
|
1343
|
-
|
|
1344
1329
|
self
|
|
1345
1330
|
.find({ $or:
|
|
1346
1331
|
[
|
|
1347
|
-
{ 'social.facebook':
|
|
1348
|
-
{ 'social.linkedin':
|
|
1349
|
-
{ 'social.twitter':
|
|
1350
|
-
{ 'crunchbase.url':
|
|
1332
|
+
{ 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
|
|
1333
|
+
{ 'social.linkedin': new RegExp('linkedin.com/company/' + username, 'i') },
|
|
1334
|
+
{ 'social.twitter': new RegExp('twitter.com/' + username, 'i') },
|
|
1335
|
+
{ 'crunchbase.url': new RegExp('crunchbase.com/organization/' + username, 'i') }
|
|
1351
1336
|
],
|
|
1352
1337
|
'deleted': { $ne: true }
|
|
1353
1338
|
})
|
package/lib/Person.js
CHANGED
|
@@ -223,7 +223,7 @@ module.exports = function(mongoose, config) {
|
|
|
223
223
|
|
|
224
224
|
Person.methods.addMerged = function(id) {
|
|
225
225
|
if (this.merged.indexOf(id) == -1) {
|
|
226
|
-
|
|
226
|
+
this.merged = this.merged.concat([id]);
|
|
227
227
|
return true;
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
@@ -715,45 +715,31 @@ module.exports = function(mongoose, config) {
|
|
|
715
715
|
var getUsername = function getUsername(val) {
|
|
716
716
|
|
|
717
717
|
var URL = require('url');
|
|
718
|
-
var
|
|
718
|
+
var parsedUrl = URL.parse(val);
|
|
719
|
+
var protocol = parsedUrl.protocol;
|
|
719
720
|
|
|
720
|
-
|
|
721
|
+
if (!protocol) { parsedUrl = URL.parse('http://' + val); }
|
|
721
722
|
|
|
722
|
-
|
|
723
|
-
if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
|
|
724
|
-
if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
|
|
723
|
+
var pathname = parsedUrl.pathname;
|
|
725
724
|
|
|
726
|
-
|
|
725
|
+
if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
|
|
726
|
+
if (pathname.indexOf('in/') === 0) { pathname = pathname.replace('in/', ''); }
|
|
727
|
+
if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
|
|
727
728
|
|
|
728
|
-
|
|
729
|
+
console.log('Username:', val, '-->', pathname);
|
|
729
730
|
|
|
730
|
-
|
|
731
|
+
return pathname;
|
|
731
732
|
|
|
732
|
-
var domains = {
|
|
733
|
-
facebook: 'https://facebook.com',
|
|
734
|
-
linkedin: 'https://linkedin.com',
|
|
735
|
-
twitter: 'https://twitter.com'
|
|
736
733
|
};
|
|
737
734
|
|
|
738
735
|
var username = getUsername(value);
|
|
739
736
|
|
|
740
|
-
// todo - tests
|
|
741
|
-
// getUsername('dhyasama');
|
|
742
|
-
// getUsername('in/dhyasama');
|
|
743
|
-
// getUsername('http://facebook.com/dhyasama');
|
|
744
|
-
// getUsername('http://linkedin.com/in/dhyasama');
|
|
745
|
-
// getUsername('https://twitter.com/dhyasama');
|
|
746
|
-
// getUsername('http://www.facebook.com/dhyasama');
|
|
747
|
-
// getUsername('http://www.linkedin.com/dhyasama/');
|
|
748
|
-
// getUsername('http://www.twitter.com/dhyasama?hello=world');
|
|
749
|
-
// getUsername('http://www.facebook.com');
|
|
750
|
-
|
|
751
737
|
self
|
|
752
738
|
.find({ $or:
|
|
753
739
|
[
|
|
754
|
-
{ 'social.facebook':
|
|
755
|
-
{ 'social.linkedin':
|
|
756
|
-
{ 'social.twitter':
|
|
740
|
+
{ 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
|
|
741
|
+
{ 'social.linkedin': new RegExp('linkedin.com/in/' + username, 'i') },
|
|
742
|
+
{ 'social.twitter': new RegExp('twitter.com/' + username, 'i') }
|
|
757
743
|
],
|
|
758
744
|
'deleted': { $ne: true }
|
|
759
745
|
})
|
|
@@ -874,7 +860,7 @@ module.exports = function(mongoose, config) {
|
|
|
874
860
|
|
|
875
861
|
this
|
|
876
862
|
.find({ 'contact.email.email': { $in : emails }, 'deleted': {$ne: true}})
|
|
877
|
-
.select('name avatarUrl')
|
|
863
|
+
.select('name avatarUrl title doNotDisplay')
|
|
878
864
|
.exec(function (err, people) {
|
|
879
865
|
cb(err, _.sortBy(people, function(person) { return person.name.full; }));
|
|
880
866
|
});
|