feat: Chat request implementation #14
11 changed files with 26 additions and 18 deletions
|
@ -23,13 +23,14 @@ use chrono::Utc;
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
use super::users::Entity as UserEntity;
|
use super::users::Entity as UserEntity;
|
||||||
|
use crate::prelude::UserId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "blacklist")]
|
#[sea_orm(table_name = "blacklist")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: UserId,
|
||||||
pub user_id: i32,
|
pub user_id: UserId,
|
||||||
/// Public key of the target
|
/// Public key of the target
|
||||||
pub target: String,
|
pub target: String,
|
||||||
pub blacklisted_at: chrono::DateTime<Utc>,
|
pub blacklisted_at: chrono::DateTime<Utc>,
|
||||||
|
|
|
@ -23,13 +23,14 @@ use chrono::Utc;
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
use super::users::Entity as UserEntity;
|
use super::users::Entity as UserEntity;
|
||||||
|
use crate::prelude::UserId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "in_chat_requests")]
|
#[sea_orm(table_name = "in_chat_requests")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: UserId,
|
||||||
pub recipient_id: i32,
|
pub recipient_id: UserId,
|
||||||
/// Public key of the sender
|
/// Public key of the sender
|
||||||
pub sender: String,
|
pub sender: String,
|
||||||
/// The timestamp of the request, when it was received
|
/// The timestamp of the request, when it was received
|
||||||
|
|
|
@ -23,13 +23,14 @@ use chrono::Utc;
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
use super::users::Entity as UserEntity;
|
use super::users::Entity as UserEntity;
|
||||||
|
use crate::prelude::UserId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "out_chat_requests")]
|
#[sea_orm(table_name = "out_chat_requests")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: UserId,
|
||||||
pub sender_id: i32,
|
pub sender_id: UserId,
|
||||||
/// Public key of the recipient
|
/// Public key of the recipient
|
||||||
pub recipient: String,
|
pub recipient: String,
|
||||||
/// The timestamp of the request, when it was sent
|
/// The timestamp of the request, when it was sent
|
||||||
|
|
|
@ -33,6 +33,9 @@ pub use sea_orm::{
|
||||||
SqlErr,
|
SqlErr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// User ID type
|
||||||
|
pub type UserId = i64;
|
||||||
|
|
||||||
pub use super::blacklist::{
|
pub use super::blacklist::{
|
||||||
ActiveModel as BlacklistActiveModel,
|
ActiveModel as BlacklistActiveModel,
|
||||||
Column as BlacklistColumn,
|
Column as BlacklistColumn,
|
||||||
|
|
|
@ -25,12 +25,13 @@ use super::blacklist::Entity as BlacklistEntity;
|
||||||
use super::incoming_chat_requests::Entity as InChatRequestsEntity;
|
use super::incoming_chat_requests::Entity as InChatRequestsEntity;
|
||||||
use super::outgoing_chat_requests::Entity as OutChatRequestsEntity;
|
use super::outgoing_chat_requests::Entity as OutChatRequestsEntity;
|
||||||
use super::whitelist::Entity as WhitelistEntity;
|
use super::whitelist::Entity as WhitelistEntity;
|
||||||
|
use crate::prelude::UserId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "users")]
|
#[sea_orm(table_name = "users")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: UserId,
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
pub is_admin: bool,
|
pub is_admin: bool,
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,14 @@ use chrono::Utc;
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
use super::users::Entity as UserEntity;
|
use super::users::Entity as UserEntity;
|
||||||
|
use crate::prelude::UserId;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "whitelist")]
|
#[sea_orm(table_name = "whitelist")]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: UserId,
|
||||||
pub user_id: i32,
|
pub user_id: UserId,
|
||||||
/// Public key of the target
|
/// Public key of the target
|
||||||
pub target: String,
|
pub target: String,
|
||||||
pub whitelisted_at: chrono::DateTime<Utc>,
|
pub whitelisted_at: chrono::DateTime<Utc>,
|
||||||
|
|
|
@ -34,12 +34,12 @@ impl MigrationTrait for Migration {
|
||||||
.if_not_exists()
|
.if_not_exists()
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(Blacklist::Id)
|
ColumnDef::new(Blacklist::Id)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null()
|
.not_null()
|
||||||
.auto_increment()
|
.auto_increment()
|
||||||
.primary_key(),
|
.primary_key(),
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(Blacklist::UserId).integer().not_null())
|
.col(ColumnDef::new(Blacklist::UserId).big_integer().not_null())
|
||||||
.col(ColumnDef::new(Blacklist::Target).string().not_null())
|
.col(ColumnDef::new(Blacklist::Target).string().not_null())
|
||||||
.col(ColumnDef::new(Blacklist::Reason).string_len(400))
|
.col(ColumnDef::new(Blacklist::Reason).string_len(400))
|
||||||
awiteb marked this conversation as resolved
|
|||||||
.col(
|
.col(
|
||||||
|
|
|
@ -34,14 +34,14 @@ impl MigrationTrait for Migration {
|
||||||
.if_not_exists()
|
.if_not_exists()
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(InChatRequests::Id)
|
ColumnDef::new(InChatRequests::Id)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null()
|
.not_null()
|
||||||
.auto_increment()
|
.auto_increment()
|
||||||
.primary_key(),
|
.primary_key(),
|
||||||
)
|
)
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(InChatRequests::RecipientId)
|
ColumnDef::new(InChatRequests::RecipientId)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null(),
|
.not_null(),
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(InChatRequests::Sender).string().not_null())
|
.col(ColumnDef::new(InChatRequests::Sender).string().not_null())
|
||||||
|
|
|
@ -34,14 +34,14 @@ impl MigrationTrait for Migration {
|
||||||
.if_not_exists()
|
.if_not_exists()
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(OutChatRequests::Id)
|
ColumnDef::new(OutChatRequests::Id)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null()
|
.not_null()
|
||||||
.auto_increment()
|
.auto_increment()
|
||||||
.primary_key(),
|
.primary_key(),
|
||||||
)
|
)
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(OutChatRequests::SenderId)
|
ColumnDef::new(OutChatRequests::SenderId)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null(),
|
.not_null(),
|
||||||
)
|
)
|
||||||
.col(
|
.col(
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl MigrationTrait for Migration {
|
||||||
.if_not_exists()
|
.if_not_exists()
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(Users::Id)
|
ColumnDef::new(Users::Id)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null()
|
.not_null()
|
||||||
.auto_increment()
|
.auto_increment()
|
||||||
.primary_key(),
|
.primary_key(),
|
||||||
|
|
|
@ -34,12 +34,12 @@ impl MigrationTrait for Migration {
|
||||||
.if_not_exists()
|
.if_not_exists()
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(Whitelist::Id)
|
ColumnDef::new(Whitelist::Id)
|
||||||
.integer()
|
.big_integer()
|
||||||
.not_null()
|
.not_null()
|
||||||
.auto_increment()
|
.auto_increment()
|
||||||
.primary_key(),
|
.primary_key(),
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(Whitelist::UserId).integer().not_null())
|
.col(ColumnDef::new(Whitelist::UserId).big_integer().not_null())
|
||||||
.col(ColumnDef::new(Whitelist::Target).string().not_null())
|
.col(ColumnDef::new(Whitelist::Target).string().not_null())
|
||||||
.col(
|
.col(
|
||||||
ColumnDef::new(Whitelist::WhitelistedAt)
|
ColumnDef::new(Whitelist::WhitelistedAt)
|
||||||
|
|
Loading…
Reference in a new issue
reason is unused
I forgot to remove it, this should be a feature soon. Is good right?
yah, if you want to add it, I think we can do in this PR, just change the whitelist table (or if we are merging both, it will be a special column for blacklist)
So we can either remove it or add it as a feature
Let's make it later, since we'll merge them.
I don't want to think about it right now