BlueGit

ict rusty-teams

refactor(endpoints): keep Teams CDN and link proxy hosts in chatsvc

- new chatsvc::teams_cdn holds the statics.teams.cdn.office.net URLs for sounds, stickers, emoticons and backgrounds
- app-base and calling read their CDN bases from it
- core external_image reuses chatsvc::links::LINK_PROXY_HOST_SUFFIX for asyncgw

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
68e37821cfeff5fcf642417c192d9a88df87ef33
Parent
a5c4bd07
8 files changed +39 −10
crates/app-base/src/emoticons/mod.rs +1 −1
@@ -9,7 +9,7 @@ use teams_core::EmoticonTag;
9 9 pub use strip::{StripImages, StripLoader, StripSource, split_strip};
10 10
11 11 const CATALOG: &str = include_str!("../../../app/assets/emoticons.tsv");
12 const ASSET_BASE: &str = "https://statics.teams.cdn.office.net/evergreen-assets/personal-expressions/v2/assets/emoticons";
12 const ASSET_BASE: &str = chatsvc::teams_cdn::EMOTICON_BASE_URL;
13 13 const ASSET_SIZE: u32 = 100;
14 14 const FRAMES_PER_SECOND: u64 = 24;
15 15 const VARIATION_SELECTOR: char = '\u{fe0f}';
@@ -9,7 +9,7 @@ use teams_core::EmoticonTag;
9pub use strip::{StripImages, StripLoader, StripSource, split_strip};
9pub use strip::{StripImages, StripLoader, StripSource, split_strip};
10
10
11const CATALOG: &str = include_str!("../../../app/assets/emoticons.tsv");
11const CATALOG: &str = include_str!("../../../app/assets/emoticons.tsv");
12const ASSET_BASE: &str = "https://statics.teams.cdn.office.net/evergreen-assets/personal-expressions/v2/assets/emoticons";
12const ASSET_BASE: &str = chatsvc::teams_cdn::EMOTICON_BASE_URL;
13const ASSET_SIZE: u32 = 100;
13const ASSET_SIZE: u32 = 100;
14const FRAMES_PER_SECOND: u64 = 24;
14const FRAMES_PER_SECOND: u64 = 24;
15const VARIATION_SELECTOR: char = '\u{fe0f}';
15const VARIATION_SELECTOR: char = '\u{fe0f}';
crates/app-base/src/notify/sound_cache.rs +1 −2
@@ -8,8 +8,7 @@ use gpui_kit::App;
8 8
9 9 use super::platform;
10 10
11 pub const TEAMS_SOUND_BASE_URL: &str =
12 "https://statics.teams.cdn.office.net/evergreen-assets/audio/";
11 pub const TEAMS_SOUND_BASE_URL: &str = chatsvc::teams_cdn::SOUND_BASE_URL;
13 12 const SOUND_DIRECTORY: &str = "sounds";
14 13 const PARTIAL_SUFFIX: &str = ".partial";
15 14
@@ -8,8 +8,7 @@ use gpui_kit::App;
8
8
9use super::platform;
9use super::platform;
10
10
11pub const TEAMS_SOUND_BASE_URL: &str =
11pub const TEAMS_SOUND_BASE_URL: &str = chatsvc::teams_cdn::SOUND_BASE_URL;
12 "https://statics.teams.cdn.office.net/evergreen-assets/audio/";
13const SOUND_DIRECTORY: &str = "sounds";
12const SOUND_DIRECTORY: &str = "sounds";
14const PARTIAL_SUFFIX: &str = ".partial";
13const PARTIAL_SUFFIX: &str = ".partial";
15
14
crates/app-base/src/stickers.rs +1 −1
@@ -1,7 +1,7 @@
1 1 use std::sync::OnceLock;
2 2
3 3 const CATALOG: &str = include_str!("../../app/assets/stickers.tsv");
4 const IMAGE_BASE: &str = "https://statics.teams.cdn.office.net/evergreen-assets/stickerassets";
4 const IMAGE_BASE: &str = chatsvc::teams_cdn::STICKER_BASE_URL;
5 5 const IMAGE_VERSION: u32 = 5;
6 6 const POPULAR_IDS: [&str; 6] = [
7 7 "Clippy_HelloThere",
@@ -1,7 +1,7 @@
1use std::sync::OnceLock;
1use std::sync::OnceLock;
2
2
3const CATALOG: &str = include_str!("../../app/assets/stickers.tsv");
3const CATALOG: &str = include_str!("../../app/assets/stickers.tsv");
4const IMAGE_BASE: &str = "https://statics.teams.cdn.office.net/evergreen-assets/stickerassets";
4const IMAGE_BASE: &str = chatsvc::teams_cdn::STICKER_BASE_URL;
5const IMAGE_VERSION: u32 = 5;
5const IMAGE_VERSION: u32 = 5;
6const POPULAR_IDS: [&str; 6] = [
6const POPULAR_IDS: [&str; 6] = [
7 "Clippy_HelloThere",
7 "Clippy_HelloThere",
crates/calling/src/background.rs +2 −2
@@ -6,8 +6,8 @@ use session::{Request, Scope, Session};
6 6
7 7 use crate::error::{Error, Result};
8 8
9 pub const CATALOG_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/backgroundimages/config.json?v=7";
10 pub const CDN_ROOT: &str = "https://statics.teams.cdn.office.net";
9 pub const CATALOG_URL: &str = chatsvc::teams_cdn::BACKGROUND_CATALOG_URL;
10 pub const CDN_ROOT: &str = chatsvc::teams_cdn::ROOT;
11 11 const FETCH_SCOPE: &str = "Chat.Read";
12 12 const MAX_SIDE: u32 = 1920;
13 13 const CATALOG_FILE: &str = "config.json";
@@ -6,8 +6,8 @@ use session::{Request, Scope, Session};
6
6
7use crate::error::{Error, Result};
7use crate::error::{Error, Result};
8
8
9pub const CATALOG_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/backgroundimages/config.json?v=7";
9pub const CATALOG_URL: &str = chatsvc::teams_cdn::BACKGROUND_CATALOG_URL;
10pub const CDN_ROOT: &str = "https://statics.teams.cdn.office.net";
10pub const CDN_ROOT: &str = chatsvc::teams_cdn::ROOT;
11const FETCH_SCOPE: &str = "Chat.Read";
11const FETCH_SCOPE: &str = "Chat.Read";
12const MAX_SIDE: u32 = 1920;
12const MAX_SIDE: u32 = 1920;
13const CATALOG_FILE: &str = "config.json";
13const CATALOG_FILE: &str = "config.json";
crates/chatsvc/src/lib.rs +1 −0
@@ -27,6 +27,7 @@ pub mod settings;
27 27 pub mod sound_settings;
28 28 pub mod sounds;
29 29 pub mod substrate_search;
30 pub mod teams_cdn;
30 31 pub mod transcripts;
31 32 pub mod translate;
32 33 pub mod window;
@@ -27,6 +27,7 @@ pub mod settings;
27pub mod sound_settings;
27pub mod sound_settings;
28pub mod sounds;
28pub mod sounds;
29pub mod substrate_search;
29pub mod substrate_search;
30pub mod teams_cdn;
30pub mod transcripts;
31pub mod transcripts;
31pub mod translate;
32pub mod translate;
32pub mod window;
33pub mod window;
crates/chatsvc/src/teams_cdn.rs added +29 −0
@@ -0,0 +1,29 @@
1 pub const HOST: &str = "statics.teams.cdn.office.net";
2 pub const ROOT: &str = "https://statics.teams.cdn.office.net";
3 pub const SOUND_BASE_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/audio/";
4 pub const STICKER_BASE_URL: &str =
5 "https://statics.teams.cdn.office.net/evergreen-assets/stickerassets";
6 pub const EMOTICON_BASE_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/personal-expressions/v2/assets/emoticons";
7 pub const BACKGROUND_CATALOG_URL: &str =
8 "https://statics.teams.cdn.office.net/evergreen-assets/backgroundimages/config.json?v=7";
9
10 #[cfg(test)]
11 mod tests {
12 use super::*;
13
14 #[test]
15 fn every_url_lives_on_the_cdn_root() {
16 assert_eq!(ROOT, format!("https://{HOST}"));
17 for url in [
18 SOUND_BASE_URL,
19 STICKER_BASE_URL,
20 EMOTICON_BASE_URL,
21 BACKGROUND_CATALOG_URL,
22 ] {
23 assert!(
24 url.starts_with(&format!("{ROOT}/evergreen-assets/")),
25 "{url}"
26 );
27 }
28 }
29 }
@@ -0,0 +1,29 @@
1pub const HOST: &str = "statics.teams.cdn.office.net";
2pub const ROOT: &str = "https://statics.teams.cdn.office.net";
3pub const SOUND_BASE_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/audio/";
4pub const STICKER_BASE_URL: &str =
5 "https://statics.teams.cdn.office.net/evergreen-assets/stickerassets";
6pub const EMOTICON_BASE_URL: &str = "https://statics.teams.cdn.office.net/evergreen-assets/personal-expressions/v2/assets/emoticons";
7pub const BACKGROUND_CATALOG_URL: &str =
8 "https://statics.teams.cdn.office.net/evergreen-assets/backgroundimages/config.json?v=7";
9
10#[cfg(test)]
11mod tests {
12 use super::*;
13
14 #[test]
15 fn every_url_lives_on_the_cdn_root() {
16 assert_eq!(ROOT, format!("https://{HOST}"));
17 for url in [
18 SOUND_BASE_URL,
19 STICKER_BASE_URL,
20 EMOTICON_BASE_URL,
21 BACKGROUND_CATALOG_URL,
22 ] {
23 assert!(
24 url.starts_with(&format!("{ROOT}/evergreen-assets/")),
25 "{url}"
26 );
27 }
28 }
29}
crates/core/src/external_image.rs +2 −2
@@ -1,9 +1,9 @@
1 1 use url::Url;
2 2
3 3 const PROXY_PATH: &str = "/urlp/v1/url/content";
4 const PROXY_HOST_SUFFIX: &str = ".asyncgw.teams.microsoft.com";
4 const PROXY_HOST_SUFFIX: &str = chatsvc::links::LINK_PROXY_HOST_SUFFIX;
5 5 const GIPHY_HOST: &str = "giphy.com";
6 const TEAMS_CDN_HOST: &str = "statics.teams.cdn.office.net";
6 const TEAMS_CDN_HOST: &str = chatsvc::teams_cdn::HOST;
7 7
8 8 /// The direct URL of a GIF or sticker image, `None` when `src` is not one of the known public hosts.
9 9 pub fn external_image_url(src: &str) -> Option<String> {
@@ -1,9 +1,9 @@
1use url::Url;
1use url::Url;
2
2
3const PROXY_PATH: &str = "/urlp/v1/url/content";
3const PROXY_PATH: &str = "/urlp/v1/url/content";
4const PROXY_HOST_SUFFIX: &str = ".asyncgw.teams.microsoft.com";
4const PROXY_HOST_SUFFIX: &str = chatsvc::links::LINK_PROXY_HOST_SUFFIX;
5const GIPHY_HOST: &str = "giphy.com";
5const GIPHY_HOST: &str = "giphy.com";
6const TEAMS_CDN_HOST: &str = "statics.teams.cdn.office.net";
6const TEAMS_CDN_HOST: &str = chatsvc::teams_cdn::HOST;
7
7
8/// The direct URL of a GIF or sticker image, `None` when `src` is not one of the known public hosts.
8/// The direct URL of a GIF or sticker image, `None` when `src` is not one of the known public hosts.
9pub fn external_image_url(src: &str) -> Option<String> {
9pub fn external_image_url(src: &str) -> Option<String> {