Skip to main content

nil_payload/request/
report.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use bon::Builder;
5use nil_core::player::PlayerId;
6use nil_core::report::ReportId;
7use nil_core::world::config::WorldId;
8use serde::{Deserialize, Serialize};
9use std::collections::HashSet;
10
11#[cfg(feature = "typescript")]
12use ts_rs::TS;
13
14#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
15#[serde(rename_all = "camelCase")]
16#[cfg_attr(feature = "typescript", derive(TS))]
17#[cfg_attr(feature = "typescript", ts(export))]
18pub struct ForwardReportRequest {
19  pub world: WorldId,
20  pub id: ReportId,
21  #[builder(into)]
22  pub recipient: PlayerId,
23}
24
25#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
26#[serde(rename_all = "camelCase")]
27#[cfg_attr(feature = "typescript", derive(TS))]
28#[cfg_attr(feature = "typescript", ts(export))]
29pub struct GetReportRequest {
30  pub world: WorldId,
31  pub id: ReportId,
32}
33
34#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
35#[serde(rename_all = "camelCase")]
36#[cfg_attr(feature = "typescript", derive(TS))]
37#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
38pub struct GetReportsRequest {
39  pub world: WorldId,
40  #[serde(default)]
41  #[builder(default, with = FromIterator::from_iter)]
42  pub ids: HashSet<ReportId>,
43  #[serde(default)]
44  pub limit: Option<u16>,
45}
46
47#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
48#[serde(rename_all = "camelCase")]
49#[cfg_attr(feature = "typescript", derive(TS))]
50#[cfg_attr(feature = "typescript", ts(export))]
51pub struct RemoveReportRequest {
52  pub world: WorldId,
53  pub id: ReportId,
54}