1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Types related to share links.
use std::sync::Arc;
use derive_more::Display;
use serde::{Deserialize, Serialize};
/// The version of the file provided by a share link.
#[derive(Debug, Display, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ShareLinkFileVersion {
/// The "current" file version in the paperless archive.
/// This version might be modified by paperless.
Archive,
/// The original file version initially uploaded to paperless.
Original,
}
/// A share link
#[derive(Debug, Clone, Deserialize)]
pub struct ShareLink {
/// Unique identifier of the share link.
pub id: crate::id::ShareLinkId,
/// Document of the share link.
pub document: crate::id::DocumentId,
/// File version of the share link.
pub file_version: ShareLinkFileVersion,
/// Slug of the share link.
pub slug: String,
#[serde(skip)]
pub(crate) base_url: Arc<str>,
}
impl ShareLink {
#[must_use]
pub fn url(&self) -> String {
format!("{}/share/{}", self.base_url, self.slug)
}
}