|
|
|
@ -18,6 +18,7 @@ export class Users extends Base { |
|
|
|
this.tryEnsureIndex({ statusConnection: 1 }, { sparse: 1 }); |
|
|
|
this.tryEnsureIndex({ statusConnection: 1 }, { sparse: 1 }); |
|
|
|
this.tryEnsureIndex({ type: 1 }); |
|
|
|
this.tryEnsureIndex({ type: 1 }); |
|
|
|
this.tryEnsureIndex({ 'visitorEmails.address': 1 }); |
|
|
|
this.tryEnsureIndex({ 'visitorEmails.address': 1 }); |
|
|
|
|
|
|
|
this.tryEnsureIndex({ federation: 1 }, { sparse: true }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getLoginTokensByUserId(userId) { |
|
|
|
getLoginTokensByUserId(userId) { |
|
|
|
@ -480,7 +481,7 @@ export class Users extends Base { |
|
|
|
return this.find(query, options); |
|
|
|
return this.find(query, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
findByActiveUsersExcept(searchTerm, exceptions, options, forcedSearchFields) { |
|
|
|
findByActiveUsersExcept(searchTerm, exceptions, options, forcedSearchFields, extraQuery = []) { |
|
|
|
if (exceptions == null) { exceptions = []; } |
|
|
|
if (exceptions == null) { exceptions = []; } |
|
|
|
if (options == null) { options = {}; } |
|
|
|
if (options == null) { options = {}; } |
|
|
|
if (!_.isArray(exceptions)) { |
|
|
|
if (!_.isArray(exceptions)) { |
|
|
|
@ -504,6 +505,7 @@ export class Users extends Base { |
|
|
|
{ |
|
|
|
{ |
|
|
|
username: { $exists: true, $nin: exceptions }, |
|
|
|
username: { $exists: true, $nin: exceptions }, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
...extraQuery, |
|
|
|
], |
|
|
|
], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -511,6 +513,26 @@ export class Users extends Base { |
|
|
|
return this._db.find(query, options); |
|
|
|
return this._db.find(query, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
findByActiveLocalUsersExcept(searchTerm, exceptions, options, forcedSearchFields, localPeer) { |
|
|
|
|
|
|
|
const extraQuery = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$or: [ |
|
|
|
|
|
|
|
{ federation: { $exists: false } }, |
|
|
|
|
|
|
|
{ 'federation.peer': localPeer }, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
return this.findByActiveUsersExcept(searchTerm, exceptions, options, forcedSearchFields, extraQuery); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
findByActiveExternalUsersExcept(searchTerm, exceptions, options, forcedSearchFields, localPeer) { |
|
|
|
|
|
|
|
const extraQuery = [ |
|
|
|
|
|
|
|
{ federation: { $exists: true } }, |
|
|
|
|
|
|
|
{ 'federation.peer': { $ne: localPeer } }, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
return this.findByActiveUsersExcept(searchTerm, exceptions, options, forcedSearchFields, extraQuery); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
findUsersByNameOrUsername(nameOrUsername, options) { |
|
|
|
findUsersByNameOrUsername(nameOrUsername, options) { |
|
|
|
const query = { |
|
|
|
const query = { |
|
|
|
username: { |
|
|
|
username: { |
|
|
|
|