Add support for CipherUpdate notifications

This commit is contained in:
Shane A. Faulkner
2018-08-31 23:30:53 -05:00
parent d70864ac73
commit b6502e9e9d
3 changed files with 51 additions and 30 deletions

View File

@ -358,4 +358,21 @@ impl Cipher {
.select(ciphers_collections::collection_uuid)
.load::<String>(&**conn).unwrap_or(vec![])
}
pub fn get_users(&self, conn: &DbConn) -> Vec<String> {
let mut user_uuids = Vec::new();
match self.user_uuid {
Some(ref user_uuid) => user_uuids.push(user_uuid.clone()),
None => { // Belongs to Organization, need to update affected users
if let Some(ref org_uuid) = self.organization_uuid {
UserOrganization::find_by_cipher_and_org(&self.uuid, &org_uuid, conn)
.iter()
.for_each(|user_org| {
user_uuids.push(user_org.user_uuid.clone())
});
}
}
};
user_uuids
}
}