mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Add iterators over * for stats, dumps, tasks, settings, and indexes; change documents impl to prevent duplication
This commit is contained in:
parent
1dc3724c1f
commit
c251b527b0
@ -92,13 +92,77 @@ impl HeedAuthStore {
|
|||||||
Action::into_enum_iter().collect()
|
Action::into_enum_iter().collect()
|
||||||
} else if key.actions.contains(&Action::DocumentsAll) {
|
} else if key.actions.contains(&Action::DocumentsAll) {
|
||||||
// if key.actions.contains.DocumentsAll add all actions related to documents.
|
// if key.actions.contains.DocumentsAll add all actions related to documents.
|
||||||
let mut actions = key.actions.clone();
|
key.actions.iter()
|
||||||
actions.append(&mut vec![
|
.cloned()
|
||||||
Action::DocumentsAdd,
|
.filter(|action|{ // Prevents duplicate entries in the actions vector
|
||||||
Action::DocumentsGet,
|
*action != Action::DocumentsAdd &&
|
||||||
Action::DocumentsDelete,
|
*action != Action::DocumentsDelete &&
|
||||||
]);
|
*action != Action::DocumentsGet
|
||||||
actions
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::DocumentsAdd,
|
||||||
|
Action::DocumentsDelete,
|
||||||
|
Action::DocumentsGet
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
|
} else if key.actions.contains(&Action::IndexesAll) {
|
||||||
|
key.actions.iter()
|
||||||
|
.cloned()
|
||||||
|
.filter(|action|{
|
||||||
|
*action != Action::IndexesAdd &&
|
||||||
|
*action != Action::IndexesGet &&
|
||||||
|
*action != Action::IndexesDelete &&
|
||||||
|
*action != Action::IndexesUpdate
|
||||||
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::IndexesAdd,
|
||||||
|
Action::IndexesGet,
|
||||||
|
Action::IndexesDelete,
|
||||||
|
Action::IndexesUpdate
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
|
} else if key.actions.contains(&Action::SettingsAll) {
|
||||||
|
key.actions.iter()
|
||||||
|
.cloned()
|
||||||
|
.filter(|action|{
|
||||||
|
*action != Action::SettingsGet &&
|
||||||
|
*action != Action::SettingsUpdate
|
||||||
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::SettingsGet,
|
||||||
|
Action::SettingsUpdate
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
|
} else if key.actions.contains(&Action::TasksAll) {
|
||||||
|
key.actions.iter()
|
||||||
|
.cloned()
|
||||||
|
.filter(|action|{
|
||||||
|
*action != Action::TasksGet
|
||||||
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::TasksGet
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
|
} else if key.actions.contains(&Action::DumpsAll) {
|
||||||
|
key.actions.iter()
|
||||||
|
.cloned()
|
||||||
|
.filter(|action|{
|
||||||
|
*action != Action::DumpsCreate
|
||||||
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::DumpsCreate
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
|
} else if key.actions.contains(&Action::StatsAll) {
|
||||||
|
key.actions.iter()
|
||||||
|
.cloned()
|
||||||
|
.filter(|action|{
|
||||||
|
*action != Action::StatsGet
|
||||||
|
})
|
||||||
|
.chain(vec![
|
||||||
|
Action::StatsGet
|
||||||
|
])
|
||||||
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
key.actions.clone()
|
key.actions.clone()
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user