BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / data.rs

data.rs

22925882 History
data.rs 22.2 KiB Download Raw
1use std::collections::{HashMap, HashSet};
2use std::path::{Path, PathBuf};
3use std::sync::Arc;
4use std::time::{Duration, Instant};
5
6use gpui_kit::{Image, ImageFormat};
7use store::{ChatRecord, Store};
8
9use teams_core::{Activity, Availability, ChatSectionSettings};
10use tokio::sync::oneshot;
11
12use crate::backend::Engine;
13use crate::runtime;
14
15const FAVORITES_KIND_MARKER: &str = "favorite";
16const RECENT_KIND_MARKER: &str = "recent";
17const MEETING_KIND_MARKER: &str = "meeting";
18const MUTED_KIND_MARKER: &str = "muted";
19const PRESENCE_MAX_AGE: Duration = Duration::from_secs(60);
20const PUSHED_PRESENCE_MAX_AGE: Duration = Duration::from_secs(5 * 60);
21const MEMBER_FACE_LIMIT: usize = 2;
22
23#[derive(Debug, Clone, PartialEq, Eq)]
24pub struct Person {
25 pub user_id: String,
26 pub display_name: String,
27}
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub enum FolderKind {
31 Favorites,
32 UserCreated,
33 Recent,
34 Meeting,
35 Muted,
36}
37
38#[derive(Debug, Clone, PartialEq, Eq)]
39pub struct FolderInfo {
40 pub id: String,
41 pub name: String,
42 pub kind: FolderKind,
43 pub expanded: Option<bool>,
44 pub conversation_ids: Vec<String>,
45}
46
47#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48pub enum PresenceKind {
49 Available,
50 Busy,
51 DoNotDisturb,
52 Away,
53 Offline,
54 Unknown,
55}
56
57impl PresenceKind {
58 pub fn label(self) -> &'static str {
59 match self {
60 PresenceKind::Available => "Available",
61 PresenceKind::Busy => "Busy",
62 PresenceKind::DoNotDisturb => "Do not disturb",
63 PresenceKind::Away => "Away",
64 PresenceKind::Offline => "Offline",
65 PresenceKind::Unknown => "",
66 }
67 }
68
69 fn code(self) -> &'static str {
70 match self {
71 PresenceKind::Available => "Available",
72 PresenceKind::Busy => "Busy",
73 PresenceKind::DoNotDisturb => "DoNotDisturb",
74 PresenceKind::Away => "Away",
75 PresenceKind::Offline => "Offline",
76 PresenceKind::Unknown => "Unknown",
77 }
78 }
79
80 fn from_code(code: &str) -> PresenceKind {
81 match code {
82 "Available" => PresenceKind::Available,
83 "Busy" => PresenceKind::Busy,
84 "DoNotDisturb" => PresenceKind::DoNotDisturb,
85 "Away" => PresenceKind::Away,
86 "Offline" => PresenceKind::Offline,
87 _ => PresenceKind::Unknown,
88 }
89 }
90}
91
92#[derive(Debug, Clone, Copy, PartialEq, Eq)]
93pub enum Presence {
94 Live(PresenceKind),
95 Cached(PresenceKind),
96 Loading,
97}
98
99impl Presence {
100 pub fn kind(self) -> PresenceKind {
101 match self {
102 Presence::Live(kind) | Presence::Cached(kind) => kind,
103 Presence::Loading => PresenceKind::Unknown,
104 }
105 }
106}
107
108#[derive(Clone)]
109pub enum AvatarState {
110 Pending,
111 Missing,
112 Ready(Arc<Image>),
113}
114
115#[derive(Debug, Clone)]
116pub struct ImageEntry {
117 pub path: PathBuf,
118 pub size: Option<(u32, u32)>,
119}
120
121#[derive(Default)]
122pub struct Directory {
123 pub me: Option<Person>,
124 pub folders: Vec<FolderInfo>,
125 pub section_settings: ChatSectionSettings,
126 pub pinned_channels: Vec<String>,
127 pub unread_counts: HashMap<String, u32>,
128 pub(crate) avatars: HashMap<String, AvatarState>,
129 pub(crate) presence: HashMap<String, (PresenceKind, Instant)>,
130 pub(crate) activity: HashMap<String, Activity>,
131 pub(crate) presence_cached: HashMap<String, PresenceKind>,
132 pub(crate) presence_requested: HashMap<String, Instant>,
133 pub(crate) presence_pending: HashSet<String>,
134 pub(crate) images: HashMap<String, ImageEntry>,
135 pub(crate) images_requested: HashSet<String>,
136 pub(crate) images_failed: HashSet<String>,
137}
138
139impl Directory {
140 pub fn avatar(&self, user_id: &str) -> Option<&AvatarState> {
141 self.avatars.get(user_id)
142 }
143
144 pub fn image(&self, key: &str) -> Option<&ImageEntry> {
145 self.images.get(key)
146 }
147
148 pub fn image_failed(&self, key: &str) -> bool {
149 self.images_failed.contains(key) && !self.images.contains_key(key)
150 }
151
152 pub fn mark_image_failed(&mut self, key: &str) {
153 self.images_failed.insert(key.to_owned());
154 }
155
156 pub fn set_image(&mut self, key: &str, path: &Path) {
157 let size = image::image_dimensions(path).ok();
158 self.images.insert(
159 key.to_owned(),
160 ImageEntry {
161 path: path.to_path_buf(),
162 size,
163 },
164 );
165 }
166
167 pub fn images_to_request(&mut self, keys: impl IntoIterator<Item = String>) -> Vec<String> {
168 keys.into_iter()
169 .filter(|key| {
170 !self.images.contains_key(key) && self.images_requested.insert(key.clone())
171 })
172 .collect()
173 }
174
175 pub fn missing_avatars(&self, user_ids: impl IntoIterator<Item = String>) -> Vec<String> {
176 let mut seen = HashSet::new();
177 user_ids
178 .into_iter()
179 .filter(|user_id| !self.avatars.contains_key(user_id) && seen.insert(user_id.clone()))
180 .collect()
181 }
182
183 pub fn mark_avatars_pending(&mut self, user_ids: &[String]) {
184 for user_id in user_ids {
185 self.avatars
186 .entry(user_id.clone())
187 .or_insert(AvatarState::Pending);
188 }
189 }
190
191 pub fn set_avatar(&mut self, user_id: &str, image: Option<Arc<Image>>) {
192 let state = image.map_or(AvatarState::Missing, AvatarState::Ready);
193 self.avatars.insert(user_id.to_owned(), state);
194 }
195
196 pub fn pending_avatars(&self) -> Vec<String> {
197 self.avatars
198 .iter()
199 .filter(|(_, state)| matches!(state, AvatarState::Pending))
200 .map(|(user_id, _)| user_id.clone())
201 .collect()
202 }
203
204 pub fn presence_of(&self, user_id: &str) -> Presence {
205 if let Some((kind, _)) = self.presence.get(user_id) {
206 return Presence::Live(*kind);
207 }
208 match self.presence_cached.get(user_id) {
209 Some(kind) => Presence::Cached(*kind),
210 None if self.presence_pending.contains(user_id) => Presence::Loading,
211 None => Presence::Live(PresenceKind::Unknown),
212 }
213 }
214
215 pub fn set_activity(&mut self, user_id: &str, activity: Option<Activity>) -> bool {
216 match activity {
217 Some(activity) => self.activity.insert(user_id.to_owned(), activity) != Some(activity),
218 None => self.activity.remove(user_id).is_some(),
219 }
220 }
221
222 pub fn status_label(&self, user_id: &str, presence: Presence) -> &'static str {
223 match self.activity.get(user_id) {
224 Some(activity) if matches!(presence, Presence::Live(_)) => activity_label(*activity),
225 _ => presence.kind().label(),
226 }
227 }
228
229 pub fn load_cached_presence(&mut self, store: &Store) {
230 self.presence_cached = store
231 .presences()
232 .unwrap_or_default()
233 .into_iter()
234 .map(|(user_id, code)| (user_id, PresenceKind::from_code(&code)))
235 .collect();
236 }
237
238 pub fn save_presence(&self, store: &Store, user_ids: &[String]) {
239 let rows: Vec<(String, String)> = user_ids
240 .iter()
241 .filter_map(|user_id| {
242 let (kind, _) = self.presence.get(user_id)?;
243 Some((user_id.clone(), kind.code().to_owned()))
244 })
245 .collect();
246 if !rows.is_empty() {
247 let _ = store.upsert_presences(&rows, chrono::Utc::now());
248 }
249 }
250
251 pub fn mark_presence_pending(&mut self, user_ids: &[String]) {
252 self.presence_pending.extend(user_ids.iter().cloned());
253 }
254
255 pub fn settle_presence(&mut self, user_ids: &[String]) {
256 for user_id in user_ids {
257 self.presence_pending.remove(user_id);
258 }
259 }
260
261 pub fn waiting_presence_ids(&self) -> Vec<String> {
262 self.presence_pending.iter().cloned().collect()
263 }
264
265 pub fn set_presence(&mut self, user_id: &str, kind: PresenceKind) -> bool {
266 self.presence
267 .insert(user_id.to_owned(), (kind, Instant::now()))
268 .is_none_or(|(previous, _)| previous != kind)
269 }
270
271 pub fn stale_presence(
272 &self,
273 user_ids: impl IntoIterator<Item = String>,
274 now: Instant,
275 pushed: bool,
276 ) -> Vec<String> {
277 let max_age = if pushed {
278 PUSHED_PRESENCE_MAX_AGE
279 } else {
280 PRESENCE_MAX_AGE
281 };
282 let mut seen = HashSet::new();
283 user_ids
284 .into_iter()
285 .filter(|user_id| {
286 let fresh = |at: &Instant| now.duration_since(*at) < max_age;
287 let known_fresh = self.presence.get(user_id).is_some_and(|(_, at)| fresh(at));
288 let asked_fresh = self.presence_requested.get(user_id).is_some_and(fresh);
289 !known_fresh && !asked_fresh && seen.insert(user_id.clone())
290 })
291 .collect()
292 }
293
294 pub fn requested_presence_ids(&self) -> Vec<String> {
295 self.presence_requested.keys().cloned().collect()
296 }
297
298 pub fn mark_presence_requested(&mut self, user_ids: &[String], now: Instant) {
299 for user_id in user_ids {
300 self.presence_requested.insert(user_id.clone(), now);
301 }
302 }
303
304 pub fn favorites(&self) -> Option<&FolderInfo> {
305 self.folders
306 .iter()
307 .find(|folder| folder.kind == FolderKind::Favorites)
308 }
309
310 pub fn folder_of(&self, conversation_id: &str) -> Option<&FolderInfo> {
311 self.folders.iter().find(|folder| {
312 folder
313 .conversation_ids
314 .iter()
315 .any(|id| id == conversation_id)
316 })
317 }
318
319 pub fn assign(&mut self, conversation_id: &str, folder_id: Option<&str>) {
320 for folder in &mut self.folders {
321 folder.conversation_ids.retain(|id| id != conversation_id);
322 }
323 if let Some(folder) =
324 folder_id.and_then(|id| self.folders.iter_mut().find(|folder| folder.id == id))
325 {
326 folder.conversation_ids.push(conversation_id.to_owned());
327 }
328 }
329}
330
331pub fn image_format(content_type: &str) -> ImageFormat {
332 let lowered = content_type.to_ascii_lowercase();
333 if lowered.contains("png") {
334 ImageFormat::Png
335 } else if lowered.contains("webp") {
336 ImageFormat::Webp
337 } else if lowered.contains("gif") {
338 ImageFormat::Gif
339 } else if lowered.contains("svg") {
340 ImageFormat::Svg
341 } else {
342 ImageFormat::Jpeg
343 }
344}
345
346pub fn is_one_on_one(chat: &ChatRecord) -> bool {
347 chat.kind.eq_ignore_ascii_case("oneOnOne")
348}
349
350pub fn others(chat: &ChatRecord, me: Option<&Person>) -> Vec<(Option<String>, String)> {
351 chat.members
352 .iter()
353 .filter(|member| match (&member.user_id, me) {
354 (Some(user_id), Some(me)) => *user_id != me.user_id,
355 _ => true,
356 })
357 .map(|member| (member.user_id.clone(), member.display_name.clone()))
358 .collect()
359}
360
361pub fn face_members(chat: &ChatRecord, me: Option<&Person>) -> Vec<(Option<String>, String)> {
362 others(chat, me)
363 .into_iter()
364 .take(MEMBER_FACE_LIMIT)
365 .collect()
366}
367
368pub fn me(store: &Store) -> Option<Person> {
369 let user_id = store.meta("me_user_id").ok().flatten()?;
370 let display_name = store
371 .meta("me_display_name")
372 .ok()
373 .flatten()
374 .unwrap_or_default();
375 Some(Person {
376 user_id,
377 display_name,
378 })
379}
380
381fn folder_kind(kind: &str) -> FolderKind {
382 let lowered = kind.to_ascii_lowercase();
383 if lowered.contains(FAVORITES_KIND_MARKER) {
384 FolderKind::Favorites
385 } else if lowered.contains(RECENT_KIND_MARKER) {
386 FolderKind::Recent
387 } else if lowered.contains(MEETING_KIND_MARKER) {
388 FolderKind::Meeting
389 } else if lowered.contains(MUTED_KIND_MARKER) {
390 FolderKind::Muted
391 } else {
392 FolderKind::UserCreated
393 }
394}
395
396pub fn folders(store: &Store, pinned_ids: &[String]) -> Vec<FolderInfo> {
397 let stored: Vec<FolderInfo> = store
398 .folders()
399 .unwrap_or_default()
400 .into_iter()
401 .map(|record| FolderInfo {
402 kind: folder_kind(&record.kind),
403 expanded: Some(record.expanded),
404 id: record.id,
405 name: record.name,
406 conversation_ids: record.conversation_ids,
407 })
408 .collect();
409 if !stored.is_empty() {
410 return stored;
411 }
412 vec![FolderInfo {
413 id: "favorites".to_owned(),
414 name: String::new(),
415 kind: FolderKind::Favorites,
416 expanded: None,
417 conversation_ids: pinned_ids.to_vec(),
418 }]
419}
420
421pub fn pinned_channels(store: &Store) -> Vec<String> {
422 store.pinned_channel_ids().unwrap_or_default()
423}
424
425pub fn cached_avatar(store: &Store, user_id: &str) -> Option<Option<Arc<Image>>> {
426 let record = store.avatar(user_id).ok().flatten()?;
427 Some(
428 record
429 .bytes
430 .map(|bytes| avatar_image_from(&record.content_type, bytes)),
431 )
432}
433
434pub fn avatar_image_from(content_type: &str, bytes: Vec<u8>) -> Arc<Image> {
435 match crate::avatar_image::circular_png(&bytes) {
436 Some(masked) => Arc::new(Image::from_bytes(ImageFormat::Png, masked)),
437 None => Arc::new(Image::from_bytes(image_format(content_type), bytes)),
438 }
439}
440
441pub fn unread_count(directory: &Directory, chat: &ChatRecord) -> Option<u32> {
442 directory.unread_counts.get(&chat.id).copied()
443}
444
445pub fn unread_counts(engine: &Engine, chats: &[ChatRecord]) -> HashMap<String, u32> {
446 chats
447 .iter()
448 .filter(|chat| chat.unread)
449 .map(|chat| (chat.id.clone(), engine.unread_count(&chat.id)))
450 .collect()
451}
452
453pub fn presence_kind_of(availability: Availability) -> PresenceKind {
454 match availability {
455 Availability::Available => PresenceKind::Available,
456 Availability::Busy => PresenceKind::Busy,
457 Availability::DoNotDisturb => PresenceKind::DoNotDisturb,
458 Availability::Away => PresenceKind::Away,
459 Availability::Offline => PresenceKind::Offline,
460 Availability::Unknown => PresenceKind::Unknown,
461 }
462}
463
464pub fn activity_label(activity: Activity) -> &'static str {
465 match activity {
466 Activity::InACall => "In a call",
467 Activity::InAConferenceCall | Activity::InAMeeting => "In a meeting",
468 Activity::Presenting => "Presenting",
469 Activity::OutOfOffice => "Out of office",
470 }
471}
472
473pub fn presence_activity(engine: &Engine, user_id: &str) -> Option<Activity> {
474 engine
475 .presence(user_id)
476 .and_then(|presence| presence.activity)
477}
478
479pub fn presence_kind(engine: &Engine, user_id: &str) -> Option<PresenceKind> {
480 engine
481 .presence(user_id)
482 .map(|presence| presence_kind_of(presence.availability))
483}
484
485pub fn in_call(engine: &Engine, user_id: &str) -> bool {
486 engine
487 .presence(user_id)
488 .is_some_and(|presence| presence.in_call())
489}
490
491pub type Done = oneshot::Receiver<Result<(), String>>;
492
493fn run<F>(future: F) -> Done
494where
495 F: std::future::Future<Output = teams_core::Result<()>> + Send + 'static,
496{
497 runtime::spawn(async move { future.await.map_err(|error| error.to_string()) })
498}
499
500pub fn fetch_image(engine: &Arc<Engine>, image: teams_core::ImageRef) -> Done {
501 let engine = engine.clone();
502 run(async move { engine.fetch_image(&image).await.map(|_| ()) })
503}
504
505pub fn fetch_avatars(engine: &Arc<Engine>, user_ids: Vec<String>) -> Done {
506 let engine = engine.clone();
507 run(async move { engine.fetch_avatars(&user_ids).await })
508}
509
510pub fn refresh_presence(engine: &Arc<Engine>, user_ids: Vec<String>) -> Done {
511 let engine = engine.clone();
512 run(async move { engine.refresh_presence(&user_ids).await })
513}
514
515pub fn watch_presence(engine: &Arc<Engine>, user_ids: Vec<String>) -> Done {
516 let engine = engine.clone();
517 run(async move { engine.watch_presence(&user_ids).await })
518}
519
520pub fn move_to_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id: &str) -> Done {
521 let (engine, conversation_id, folder_id) = (
522 engine.clone(),
523 conversation_id.to_owned(),
524 folder_id.to_owned(),
525 );
526 run(async move { engine.move_to_folder(&conversation_id, &folder_id).await })
527}
528
529pub fn remove_from_folder(engine: &Arc<Engine>, conversation_id: &str, folder_id: &str) -> Done {
530 let (engine, conversation_id, folder_id) = (
531 engine.clone(),
532 conversation_id.to_owned(),
533 folder_id.to_owned(),
534 );
535 run(async move {
536 engine
537 .remove_from_folder(&conversation_id, &folder_id)
538 .await
539 })
540}
541
542#[cfg(test)]
543mod tests {
544 use super::*;
545
546 #[test]
547 fn activity_wording_replaces_availability_only_for_live_presence() {
548 let cases = [
549 (Activity::InACall, "In a call"),
550 (Activity::InAConferenceCall, "In a meeting"),
551 (Activity::InAMeeting, "In a meeting"),
552 (Activity::Presenting, "Presenting"),
553 (Activity::OutOfOffice, "Out of office"),
554 ];
555 for (activity, label) in cases {
556 let mut directory = Directory::default();
557 directory.set_activity("ada", Some(activity));
558 let live = Presence::Live(PresenceKind::Busy);
559 assert_eq!(directory.status_label("ada", live), label);
560 assert_eq!(
561 directory.status_label("ada", Presence::Cached(PresenceKind::Busy)),
562 "Busy"
563 );
564 assert_eq!(directory.status_label("bob", live), "Busy");
565 assert!(directory.set_activity("ada", None));
566 assert_eq!(directory.status_label("ada", live), "Busy");
567 }
568 }
569
570 fn folder(id: &str, kind: FolderKind, ids: &[&str]) -> FolderInfo {
571 FolderInfo {
572 id: id.into(),
573 name: id.into(),
574 kind,
575 expanded: None,
576 conversation_ids: ids.iter().map(|id| (*id).to_owned()).collect(),
577 }
578 }
579
580 #[test]
581 fn assign_moves_a_chat_between_folders() {
582 let mut directory = Directory {
583 folders: vec![
584 folder("fav", FolderKind::Favorites, &["a"]),
585 folder("work", FolderKind::UserCreated, &["b"]),
586 ],
587 ..Default::default()
588 };
589 directory.assign("a", Some("work"));
590 assert!(directory.favorites().unwrap().conversation_ids.is_empty());
591 assert_eq!(directory.folders[1].conversation_ids, vec!["b", "a"]);
592 directory.assign("a", None);
593 assert!(directory.folder_of("a").is_none());
594 }
595
596 #[test]
597 fn missing_avatars_skip_known_and_duplicates() {
598 let mut directory = Directory::default();
599 directory.set_avatar("known", None);
600 let wanted = directory.missing_avatars(["known", "x", "x", "y"].map(String::from));
601 assert_eq!(wanted, vec!["x", "y"]);
602 directory.mark_avatars_pending(&wanted);
603 assert!(directory.missing_avatars(["x".to_owned()]).is_empty());
604 assert_eq!(directory.pending_avatars().len(), 2);
605 }
606
607 #[test]
608 fn a_failed_image_is_only_failed_until_it_arrives() {
609 let mut directory = Directory::default();
610 assert!(!directory.image_failed("a"));
611 directory.mark_image_failed("a");
612 assert!(directory.image_failed("a"));
613 directory.set_image("a", Path::new("a.png"));
614 assert!(!directory.image_failed("a"));
615 }
616
617 #[test]
618 fn images_are_requested_once() {
619 let mut directory = Directory::default();
620 let wanted = directory.images_to_request(["a", "a", "b"].map(String::from));
621 assert_eq!(wanted, vec!["a", "b"]);
622 assert!(directory.images_to_request(["a".to_owned()]).is_empty());
623 }
624
625 #[test]
626 fn presence_is_refetched_after_the_max_age() {
627 let mut directory = Directory::default();
628 let start = Instant::now();
629 let wanted = directory.stale_presence(["u".to_owned()], start, false);
630 assert_eq!(wanted, vec!["u"]);
631 directory.mark_presence_requested(&wanted, start);
632 assert!(
633 directory
634 .stale_presence(["u".to_owned()], start, false)
635 .is_empty()
636 );
637 let later = start + PRESENCE_MAX_AGE + Duration::from_secs(1);
638 assert_eq!(
639 directory.stale_presence(["u".to_owned()], later, false),
640 vec!["u"]
641 );
642 assert!(
643 directory
644 .stale_presence(["u".to_owned()], later, true)
645 .is_empty()
646 );
647 let much_later = start + PUSHED_PRESENCE_MAX_AGE + Duration::from_secs(1);
648 assert_eq!(
649 directory.stale_presence(["u".to_owned()], much_later, true),
650 vec!["u"]
651 );
652 assert_eq!(directory.presence_of("u").kind(), PresenceKind::Unknown);
653 }
654
655 #[test]
656 fn presence_prefers_live_over_cached_over_loading() {
657 let mut directory = Directory::default();
658 let ids = ["a".to_owned(), "b".to_owned(), "c".to_owned()];
659 directory.mark_presence_pending(&ids);
660 directory
661 .presence_cached
662 .insert("b".into(), PresenceKind::Away);
663 directory
664 .presence_cached
665 .insert("c".into(), PresenceKind::Away);
666 directory.set_presence("c", PresenceKind::Busy);
667 assert_eq!(directory.presence_of("a"), Presence::Loading);
668 assert_eq!(
669 directory.presence_of("b"),
670 Presence::Cached(PresenceKind::Away)
671 );
672 assert_eq!(
673 directory.presence_of("c"),
674 Presence::Live(PresenceKind::Busy)
675 );
676 directory.settle_presence(&ids);
677 assert_eq!(
678 directory.presence_of("a"),
679 Presence::Live(PresenceKind::Unknown)
680 );
681 }
682
683 #[test]
684 fn presence_survives_a_restart_through_the_store() {
685 let store = Store::open_in_memory().unwrap();
686 let mut directory = Directory::default();
687 directory.set_presence("a", PresenceKind::DoNotDisturb);
688 directory.save_presence(&store, &["a".to_owned(), "missing".to_owned()]);
689 let mut restarted = Directory::default();
690 restarted.load_cached_presence(&store);
691 assert_eq!(
692 restarted.presence_of("a"),
693 Presence::Cached(PresenceKind::DoNotDisturb)
694 );
695 assert_eq!(
696 restarted.presence_of("missing"),
697 Presence::Live(PresenceKind::Unknown)
698 );
699 }
700
701 #[test]
702 fn content_types_map_to_image_formats() {
703 assert_eq!(image_format("image/png"), ImageFormat::Png);
704 assert_eq!(image_format("image/jpeg"), ImageFormat::Jpeg);
705 assert_eq!(image_format(""), ImageFormat::Jpeg);
706 }
707}