]> Untitled Git - lemmy.git/blob - crates/apub/src/context.rs
Adding unique constraint for activity ap_id. Fixes #1878 (#1935)
[lemmy.git] / crates / apub / src / context.rs
1 use serde::{Deserialize, Serialize};
2
3 lazy_static! {
4   static ref CONTEXT: Vec<serde_json::Value> =
5     serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context");
6 }
7
8 #[derive(Serialize, Deserialize, Debug)]
9 pub(crate) struct WithContext<T> {
10   #[serde(rename = "@context")]
11   context: Vec<serde_json::Value>,
12   #[serde(flatten)]
13   inner: T,
14 }
15
16 impl<T> WithContext<T> {
17   pub(crate) fn new(inner: T) -> WithContext<T> {
18     WithContext {
19       context: CONTEXT.clone(),
20       inner,
21     }
22   }
23   pub(crate) fn inner(self) -> T {
24     self.inner
25   }
26 }