feat: Add accepted_response
col to incoming_chat
table
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
f0383296de
commit
c8693eeb3e
3 changed files with 23 additions and 7 deletions
|
@ -47,9 +47,13 @@ impl IncomingChatExt for DatabaseConnection {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.on_conflict(
|
.on_conflict(
|
||||||
OnConflict::columns([IncomingChatColumn::RecipientId, IncomingChatColumn::Sender])
|
OnConflict::columns([
|
||||||
.do_nothing()
|
IncomingChatColumn::RecipientId,
|
||||||
.to_owned(),
|
IncomingChatColumn::Sender,
|
||||||
|
IncomingChatColumn::AcceptedResponse,
|
||||||
|
])
|
||||||
|
.do_nothing()
|
||||||
|
.to_owned(),
|
||||||
)
|
)
|
||||||
.exec(self)
|
.exec(self)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -31,12 +31,15 @@ use crate::prelude::*;
|
||||||
#[sea_orm(table_name = "incoming_chat")]
|
#[sea_orm(table_name = "incoming_chat")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: IdCol,
|
pub id: IdCol,
|
||||||
pub recipient_id: IdCol,
|
pub recipient_id: IdCol,
|
||||||
/// Public key of the sender
|
/// Public key of the sender
|
||||||
pub sender: PublicKey,
|
pub sender: PublicKey,
|
||||||
|
/// Whether the chat response accepted or not.
|
||||||
|
/// This will be `None` if it is chat request, otherwise `bool`
|
||||||
|
pub accepted_response: Option<bool>,
|
||||||
/// The timestamp of the request, when it was received
|
/// The timestamp of the request, when it was received
|
||||||
pub in_on: chrono::DateTime<Utc>,
|
pub in_on: chrono::DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
|
|
@ -58,6 +58,12 @@ impl MigrationTrait for Migration {
|
||||||
.on_delete(ForeignKeyAction::Cascade),
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(IncomingChat::Sender).binary().not_null())
|
.col(ColumnDef::new(IncomingChat::Sender).binary().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(IncomingChat::AcceptedResponse)
|
||||||
|
.boolean()
|
||||||
|
.null()
|
||||||
|
.default(Option::<bool>::None),
|
||||||
|
)
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(IncomingChat::InOn)
|
ColumnDef::new(IncomingChat::InOn)
|
||||||
.timestamp_with_time_zone()
|
.timestamp_with_time_zone()
|
||||||
|
@ -74,6 +80,7 @@ impl MigrationTrait for Migration {
|
||||||
.table(IncomingChat::Table)
|
.table(IncomingChat::Table)
|
||||||
.col(IncomingChat::RecipientId)
|
.col(IncomingChat::RecipientId)
|
||||||
.col(IncomingChat::Sender)
|
.col(IncomingChat::Sender)
|
||||||
|
.col(IncomingChat::AcceptedResponse)
|
||||||
.unique()
|
.unique()
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
)
|
)
|
||||||
|
@ -88,5 +95,7 @@ enum IncomingChat {
|
||||||
RecipientId,
|
RecipientId,
|
||||||
/// Public key of the sender
|
/// Public key of the sender
|
||||||
Sender,
|
Sender,
|
||||||
|
/// Whether the chat response accepted or not
|
||||||
|
AcceptedResponse,
|
||||||
InOn,
|
InOn,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue