Simplify notification serialization
This commit is contained in:
parent
83fb8d20b7
commit
5a0afcc835
4 changed files with 29 additions and 40 deletions
|
@ -13,6 +13,7 @@ use anyhow::anyhow;
|
|||
use collections::{BTreeMap, HashMap, HashSet};
|
||||
use dashmap::DashMap;
|
||||
use futures::StreamExt;
|
||||
use queries::channels::ChannelGraph;
|
||||
use rand::{prelude::StdRng, Rng, SeedableRng};
|
||||
use rpc::{
|
||||
proto::{self},
|
||||
|
@ -47,8 +48,6 @@ pub use ids::*;
|
|||
pub use sea_orm::ConnectOptions;
|
||||
pub use tables::user::Model as User;
|
||||
|
||||
use self::queries::channels::ChannelGraph;
|
||||
|
||||
pub struct Database {
|
||||
options: ConnectOptions,
|
||||
pool: DatabaseConnection,
|
||||
|
|
|
@ -76,10 +76,10 @@ impl Database {
|
|||
notification: Notification,
|
||||
tx: &DatabaseTransaction,
|
||||
) -> Result<proto::Notification> {
|
||||
let notification = notification.to_any();
|
||||
let notification = notification.to_proto();
|
||||
let kind = *self
|
||||
.notification_kinds_by_name
|
||||
.get(notification.kind.as_ref())
|
||||
.get(¬ification.kind)
|
||||
.ok_or_else(|| anyhow!("invalid notification kind {:?}", notification.kind))?;
|
||||
|
||||
let model = notification::ActiveModel {
|
||||
|
@ -110,10 +110,10 @@ impl Database {
|
|||
notification: Notification,
|
||||
tx: &DatabaseTransaction,
|
||||
) -> Result<Option<NotificationId>> {
|
||||
let notification = notification.to_any();
|
||||
let notification = notification.to_proto();
|
||||
let kind = *self
|
||||
.notification_kinds_by_name
|
||||
.get(notification.kind.as_ref())
|
||||
.get(¬ification.kind)
|
||||
.ok_or_else(|| anyhow!("invalid notification kind {:?}", notification.kind))?;
|
||||
let actor_id = notification.actor_id.map(|id| UserId::from_proto(id));
|
||||
let notification = notification::Entity::find()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue