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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Namespace: "chat.1"
// Protocol: "unfurl"
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Serialize, Deserialize};
use serde_repr::{Deserialize_repr, Serialize_repr};use super::*;

use super::common::*;
#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum UnfurlType {
  Generic_0,
  Youtube_1,
  Giphy_2,
  Maps_3, // only from scrape, gets converted to generic in packager
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlVideo {
  #[serde(default)]
  pub url: Option<String>,
  #[serde(default)]
  pub mimeType: Option<String>,
  pub height: Option<i32>,
  pub width: Option<i32>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGenericRaw {
  #[serde(default)]
  pub title: Option<String>,
  #[serde(default)]
  pub url: Option<String>,
  #[serde(default)]
  pub siteName: Option<String>,
  pub faviconUrl: Option<String>,
  pub imageUrl: Option<String>,
  pub video: Option<UnfurlVideo>,
  pub publishTime: Option<i32>,
  pub description: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlYoutubeRaw {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGiphyRaw {
  pub imageUrl: Option<String>,
  pub video: Option<UnfurlVideo>,
  pub faviconUrl: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlMapsRaw {
  #[serde(default)]
  pub title: Option<String>,
  #[serde(default)]
  pub url: Option<String>,
  #[serde(default)]
  pub siteName: Option<String>,
  #[serde(default)]
  pub imageUrl: Option<String>,
  pub historyImageUrl: Option<String>,
  #[serde(default)]
  pub description: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum UnfurlRaw {
  Generic {generic: UnfurlGenericRaw},
  Youtube {youtube: UnfurlYoutubeRaw},
  Giphy {giphy: UnfurlGiphyRaw},
  Maps {maps: UnfurlMapsRaw},
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGeneric {
  #[serde(default)]
  pub title: Option<String>,
  #[serde(default)]
  pub url: Option<String>,
  #[serde(default)]
  pub siteName: Option<String>,
  pub favicon: Option<Asset>,
  pub image: Option<Asset>,
  pub publishTime: Option<i32>,
  pub description: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlYoutube {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGiphy {
  pub favicon: Option<Asset>,
  pub image: Option<Asset>,
  pub video: Option<Asset>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum Unfurl {
  Generic {generic: UnfurlGeneric},
  Youtube {youtube: UnfurlYoutube},
  Giphy {giphy: UnfurlGiphy},
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlResult {
  pub unfurl: Option<Unfurl>,
  #[serde(default)]
  pub url: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlImageDisplay {
  #[serde(default)]
  pub url: Option<String>,
  pub height: Option<i32>,
  pub width: Option<i32>,
  #[serde(default)]
  pub isVideo: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGenericDisplay {
  #[serde(default)]
  pub title: Option<String>,
  #[serde(default)]
  pub url: Option<String>,
  #[serde(default)]
  pub siteName: Option<String>,
  pub favicon: Option<UnfurlImageDisplay>,
  pub media: Option<UnfurlImageDisplay>,
  pub publishTime: Option<i32>,
  pub description: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlYoutubeDisplay {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlGiphyDisplay {
  pub favicon: Option<UnfurlImageDisplay>,
  pub image: Option<UnfurlImageDisplay>,
  pub video: Option<UnfurlImageDisplay>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum UnfurlDisplay {
  Generic {generic: UnfurlGenericDisplay},
  Youtube {youtube: UnfurlYoutubeDisplay},
  Giphy {giphy: UnfurlGiphyDisplay},
}

#[derive(Serialize_repr, Deserialize_repr, Debug, Hash, PartialEq, Eq)]
#[repr(u8)]
pub enum UnfurlMode {
  Always_0,
  Never_1,
  Whitelisted_2,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlSettings {
  pub mode: Option<UnfurlMode>,
  pub whitelist: Option<std::collections::HashMap<String, bool>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UnfurlSettingsDisplay {
  pub mode: Option<UnfurlMode>,
  #[serde(default)]
  pub whitelist: Option<Vec<String>>,
}