Skip to content

Commit a06e58b

Browse files
committed
fix(slack): harden hosted channel discovery
1 parent 7ac1e8a commit a06e58b

6 files changed

Lines changed: 443 additions & 48 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"ok": true,
3+
"channels": [
4+
{
5+
"id": "C08ENGINEER1",
6+
"context_team_id": "T08LOCALITY1",
7+
"team_id": "T08LOCALITY1",
8+
"name": "engineering",
9+
"created": 1780000000,
10+
"updated": "malformed-timestamp-secret",
11+
"is_archived": false,
12+
"is_private": true,
13+
"is_shared": false,
14+
"is_ext_shared": false,
15+
"is_org_shared": false,
16+
"is_member": true,
17+
"shared_team_ids": [
18+
"T08LOCALITY1"
19+
]
20+
}
21+
],
22+
"response_metadata": {
23+
"next_cursor": ""
24+
}
25+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"ok": true,
3+
"headers": {
4+
"Authorization": "Bearer discovery-secret"
5+
},
6+
"cookies": "discovery-cookie",
7+
"channels": [
8+
{
9+
"id": "C08ENGINEER1",
10+
"context_team_id": "T08LOCALITY1",
11+
"team_id": "T08LOCALITY1",
12+
"name": "engineering",
13+
"topic": {
14+
"value": "Build safely",
15+
"creator": "U08TOPIC001"
16+
},
17+
"purpose": {
18+
"value": "Engineering"
19+
},
20+
"created": 1780000000,
21+
"updated": 1780000010123,
22+
"is_archived": false,
23+
"is_private": true,
24+
"is_shared": false,
25+
"is_ext_shared": false,
26+
"is_org_shared": false,
27+
"is_member": true,
28+
"shared_team_ids": [
29+
"T08LOCALITY1"
30+
],
31+
"latest": {
32+
"text": "private-message-secret",
33+
"files": [
34+
{
35+
"url_private": "https://provider.invalid/discovery-file-secret"
36+
}
37+
]
38+
},
39+
"creator_profile": {
40+
"email": "discovery-secret@example.invalid"
41+
}
42+
}
43+
],
44+
"response_metadata": {
45+
"next_cursor": "page-two"
46+
}
47+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"ok": true,
3+
"channels": [
4+
{
5+
"id": "C08GENERAL01",
6+
"context_team_id": "T08LOCALITY1",
7+
"team_id": "T08LOCALITY1",
8+
"name": "general",
9+
"topic": {
10+
"value": ""
11+
},
12+
"purpose": {
13+
"value": ""
14+
},
15+
"created": 1780000020,
16+
"is_archived": true,
17+
"is_private": false,
18+
"is_shared": false,
19+
"is_ext_shared": false,
20+
"is_org_shared": false,
21+
"is_member": false,
22+
"shared_team_ids": []
23+
}
24+
],
25+
"response_metadata": {
26+
"next_cursor": ""
27+
}
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"channel": {
3+
"team_id": "T08LOCALITY1",
4+
"id": "C08ENGINEER1",
5+
"name": "engineering",
6+
"topic": "Build safely",
7+
"purpose": "Engineering",
8+
"created_ts": "1780000000.000000",
9+
"updated_ts": "1780000010.123000",
10+
"sharing": "private"
11+
},
12+
"is_member": true,
13+
"is_archived": false
14+
}

crates/locality-slack/src/dto.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct SlackConversation {
3333
pub is_member: Option<bool>,
3434
#[serde(default)]
3535
pub is_archived: bool,
36+
/// Raw epoch-millisecond channel-settings timestamp from Slack.
3637
#[serde(default)]
3738
pub updated: Option<u64>,
3839
#[serde(default)]
@@ -189,7 +190,7 @@ mod tests {
189190
"is_mpim": false,
190191
"is_archived": false,
191192
"is_private": false,
192-
"updated": 1780000000000000,
193+
"updated": 1780000000123,
193194
"num_members": 12,
194195
"topic": { "value": "Company-wide updates" },
195196
"purpose": { "value": "Announcements" }
@@ -202,6 +203,7 @@ mod tests {
202203
assert!(page.ok);
203204
assert_eq!(page.channels[0].id, "C123");
204205
assert_eq!(page.channels[0].name.as_deref(), Some("general"));
206+
assert_eq!(page.channels[0].updated, Some(1_780_000_000_123));
205207
assert_eq!(page.response_metadata.next_cursor.as_deref(), Some("abc"));
206208
}
207209

0 commit comments

Comments
 (0)