79 lines
1.9 KiB
Rust
79 lines
1.9 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use models::{ProjectId, RoomId, UserId, Uuid};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum InviteEventType {
|
|
Created,
|
|
Accepted,
|
|
Rejected,
|
|
Revoked,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum InviteEvent {
|
|
Created(InviteCreatedService),
|
|
Accepted(InviteAcceptedService),
|
|
Rejected(InviteRejectedService),
|
|
Revoked(InviteRevokedService),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct InviteCreatedService {
|
|
pub id: Uuid,
|
|
pub project: ProjectId,
|
|
pub room: Option<RoomId>,
|
|
pub inviter: UserId,
|
|
pub invitee: Option<UserId>,
|
|
pub code: String,
|
|
pub max_uses: Option<i32>,
|
|
pub expires_at: Option<DateTime<Utc>>,
|
|
pub created_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct InviteAcceptedService {
|
|
pub id: Uuid,
|
|
pub project: ProjectId,
|
|
pub room: Option<RoomId>,
|
|
pub user: UserId,
|
|
pub accepted_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct InviteRejectedService {
|
|
pub id: Uuid,
|
|
pub project: ProjectId,
|
|
pub user: UserId,
|
|
pub rejected_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct InviteRevokedService {
|
|
pub id: Uuid,
|
|
pub project: ProjectId,
|
|
pub revoked_by: UserId,
|
|
pub revoked_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct InviteCreateClient {
|
|
pub project: ProjectId,
|
|
pub room: Option<RoomId>,
|
|
pub max_uses: Option<i32>,
|
|
pub expires_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct InviteAcceptClient {
|
|
pub code: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct InviteRevokeClient {
|
|
pub id: Uuid,
|
|
}
|