1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

storage: split the repository trait

This commit is contained in:
Quentin Gliech
2023-01-24 16:04:18 +01:00
parent 6a8c79c497
commit d14ca156ad
18 changed files with 401 additions and 308 deletions

View File

@@ -32,7 +32,7 @@ mod tests {
CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository,
},
user::UserRepository,
Clock, Repository,
Clock, Repository, RepositoryAccess,
};
use rand::SeedableRng;
use rand_chacha::ChaChaRng;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Interactions with the database
//! An implementation of the storage traits for a PostgreSQL database
#![forbid(unsafe_code)]
#![deny(

View File

@@ -27,7 +27,7 @@ use mas_storage::{
UpstreamOAuthSessionRepository,
},
user::{BrowserSessionRepository, UserEmailRepository, UserPasswordRepository, UserRepository},
Repository,
Repository, RepositoryAccess, RepositoryTransaction,
};
use sqlx::{PgPool, Postgres, Transaction};
@@ -62,7 +62,9 @@ impl PgRepository {
}
}
impl Repository for PgRepository {
impl Repository<DatabaseError> for PgRepository {}
impl RepositoryTransaction for PgRepository {
type Error = DatabaseError;
fn save(self: Box<Self>) -> BoxFuture<'static, Result<(), Self::Error>> {
@@ -72,6 +74,10 @@ impl Repository for PgRepository {
fn cancel(self: Box<Self>) -> BoxFuture<'static, Result<(), Self::Error>> {
self.txn.rollback().map_err(DatabaseError::from).boxed()
}
}
impl RepositoryAccess for PgRepository {
type Error = DatabaseError;
fn upstream_oauth_link<'c>(
&'c mut self,

View File

@@ -31,7 +31,7 @@ mod tests {
UpstreamOAuthSessionRepository,
},
user::UserRepository,
Pagination, Repository,
Pagination, RepositoryAccess,
};
use oauth2_types::scope::{Scope, OPENID};
use rand::SeedableRng;

View File

@@ -16,7 +16,7 @@ use chrono::Duration;
use mas_storage::{
clock::MockClock,
user::{BrowserSessionRepository, UserEmailRepository, UserPasswordRepository, UserRepository},
Repository,
Repository, RepositoryAccess,
};
use rand::SeedableRng;
use rand_chacha::ChaChaRng;