replace url field with scope, change app version

This commit is contained in:
yggverse 2024-11-27 22:08:58 +02:00
parent 2e17858a39
commit 45f82e7837
4 changed files with 33 additions and 33 deletions

View file

@ -23,19 +23,19 @@ impl Memory {
// Actions
/// Add new record with `url` as key and `profile_identity_gemini_id` as value
/// Add new record with `scope` as key and `profile_identity_gemini_id` as value
/// * validate record with same key does not exist yet
pub fn add(&self, url: String, profile_identity_gemini_id: i64) -> Result<(), Error> {
pub fn add(&self, scope: String, profile_identity_gemini_id: i64) -> Result<(), Error> {
// Borrow shared index access
let mut index = self.index.borrow_mut();
// Prevent existing key overwrite
if index.contains_key(&url) {
return Err(Error::Overwrite(url));
if index.contains_key(&scope) {
return Err(Error::Overwrite(scope));
}
// Slot should be free, let check it twice
match index.insert(url, profile_identity_gemini_id) {
match index.insert(scope, profile_identity_gemini_id) {
Some(_) => Err(Error::Unexpected),
None => Ok(()),
}
@ -58,7 +58,7 @@ impl Memory {
pub fn match_priority(&self, request: &str) -> Option<Auth> {
let mut result = Vec::new();
// Get all records starts with URL cached, collect length for priority
// Get all records starts with `scope` cached
for (scope, &profile_identity_gemini_id) in self.index.borrow().iter() {
if request.starts_with(scope) {
result.push(Auth {