[IMPROVE] Replace userAutocomplete publication by REST (#15956)
parent
5bd373c8d7
commit
1bac45960a
@ -1,4 +1,4 @@ |
||||
app/theme/client/vendor/fontello/css/fontello.css |
||||
packages/meteor-autocomplete/client/autocomplete.css |
||||
app/meteor-autocomplete/client/autocomplete.css |
||||
app/katex/katex.min.css |
||||
app/emoji-emojione/client/*.css |
||||
|
||||
@ -0,0 +1,24 @@ |
||||
import { Rooms } from '../../../models/server/raw'; |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
|
||||
export async function findChannelAndPrivateAutocomplete({ uid, selector }) { |
||||
if (!await hasPermissionAsync(uid, 'view-other-user-channels')) { |
||||
return { items: [] }; |
||||
} |
||||
const options = { |
||||
fields: { |
||||
_id: 1, |
||||
name: 1, |
||||
}, |
||||
limit: 10, |
||||
sort: { |
||||
name: 1, |
||||
}, |
||||
}; |
||||
|
||||
const rooms = await Rooms.findChannelAndPrivateByNameStarting(selector.name, options).toArray(); |
||||
|
||||
return { |
||||
items: rooms, |
||||
}; |
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
import { Users } from '../../../models/server/raw'; |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
|
||||
export async function findUsersToAutocomplete({ uid, selector }) { |
||||
if (!await hasPermissionAsync(uid, 'view-outside-room')) { |
||||
return { items: [] }; |
||||
} |
||||
const exceptions = selector.exceptions || []; |
||||
const conditions = selector.conditions || {}; |
||||
const options = { |
||||
fields: { |
||||
name: 1, |
||||
username: 1, |
||||
status: 1, |
||||
}, |
||||
sort: { |
||||
username: 1, |
||||
}, |
||||
limit: 10, |
||||
}; |
||||
|
||||
const users = await Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions(selector.term, exceptions, conditions, options).toArray(); |
||||
|
||||
return { |
||||
items: users, |
||||
}; |
||||
} |
||||
@ -0,0 +1,3 @@ |
||||
import { Mongo } from 'meteor/mongo'; |
||||
|
||||
export default new Mongo.Collection(null); |
||||
@ -1,3 +0,0 @@ |
||||
import { Mongo } from 'meteor/mongo'; |
||||
|
||||
export default new Mongo.Collection('autocompleteRecords'); |
||||
@ -1,23 +0,0 @@ |
||||
Package.describe({ |
||||
name: 'mizzao:autocomplete', |
||||
summary: 'Client/server autocompletion designed for Meteor\'s collections and reactivity', |
||||
version: '0.5.1', |
||||
git: 'https://github.com/mizzao/meteor-autocomplete.git', |
||||
}); |
||||
|
||||
Package.onUse(function(api) { |
||||
api.use([ |
||||
'ecmascript', |
||||
'mongo', |
||||
'ddp', |
||||
]); |
||||
api.use([ |
||||
'blaze', |
||||
'templating', |
||||
'jquery', |
||||
'dandv:caret-position@2.1.0-3', |
||||
], 'client'); |
||||
api.addFiles('client/autocomplete.css', 'client'); |
||||
api.mainModule('client/index.js', 'client'); |
||||
api.mainModule('server/index.js', 'server'); |
||||
}); |
||||
Loading…
Reference in new issue