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  #[builder(start_fn, into)]
20  pub world: WorldId,
21  pub id: ReportId,
22  #[builder(into)]
23  pub recipient: PlayerId,
24}
25
26#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
27#[serde(rename_all = "camelCase")]
28#[cfg_attr(feature = "typescript", derive(TS))]
29#[cfg_attr(feature = "typescript", ts(export))]
30pub struct GetReportRequest {
31  #[builder(start_fn, into)]
32  pub world: WorldId,
33  pub id: ReportId,
34}
35
36#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
37#[serde(rename_all = "camelCase")]
38#[cfg_attr(feature = "typescript", derive(TS))]
39#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
40pub struct GetReportsRequest {
41  #[builder(start_fn, into)]
42  pub world: WorldId,
43  #[serde(default)]
44  #[builder(default, with = FromIterator::from_iter)]
45  pub ids: HashSet<ReportId>,
46  #[serde(default)]
47  pub limit: Option<u16>,
48}
49
50#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
51#[serde(rename_all = "camelCase")]
52#[cfg_attr(feature = "typescript", derive(TS))]
53#[cfg_attr(feature = "typescript", ts(export))]
54pub struct RemoveReportRequest {
55  #[builder(start_fn, into)]
56  pub world: WorldId,
57  pub id: ReportId,
58}