refactor: Refactor in_chat_requests
table #35
3 changed files with 23 additions and 7 deletions
|
@ -47,7 +47,11 @@ impl IncomingChatExt for DatabaseConnection {
|
|||
..Default::default()
|
||||
})
|
||||
.on_conflict(
|
||||
OnConflict::columns([IncomingChatColumn::RecipientId, IncomingChatColumn::Sender])
|
||||
OnConflict::columns([
|
||||
IncomingChatColumn::RecipientId,
|
||||
IncomingChatColumn::Sender,
|
||||
IncomingChatColumn::AcceptedResponse,
|
||||
])
|
||||
.do_nothing()
|
||||
.to_owned(),
|
||||
)
|
||||
|
|
|
@ -35,6 +35,9 @@ pub struct Model {
|
|||
pub recipient_id: IdCol,
|
||||
/// Public key of the sender
|
||||
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
|
||||
pub in_on: chrono::DateTime<Utc>,
|
||||
}
|
||||
|
|
|
@ -58,6 +58,12 @@ impl MigrationTrait for Migration {
|
|||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.col(ColumnDef::new(IncomingChat::Sender).binary().not_null())
|
||||
.col(
|
||||
ColumnDef::new(IncomingChat::AcceptedResponse)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(Option::<bool>::None),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(IncomingChat::InOn)
|
||||
.timestamp_with_time_zone()
|
||||
|
@ -74,6 +80,7 @@ impl MigrationTrait for Migration {
|
|||
.table(IncomingChat::Table)
|
||||
.col(IncomingChat::RecipientId)
|
||||
.col(IncomingChat::Sender)
|
||||
.col(IncomingChat::AcceptedResponse)
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
|
@ -88,5 +95,7 @@ enum IncomingChat {
|
|||
RecipientId,
|
||||
/// Public key of the sender
|
||||
Sender,
|
||||
/// Whether the chat response accepted or not
|
||||
AcceptedResponse,
|
||||
InOn,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue