Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sub-thread starting points #46

Closed
mwarkentin opened this issue May 26, 2023 · 7 comments · Fixed by #60
Closed

Support sub-thread starting points #46

mwarkentin opened this issue May 26, 2023 · 7 comments · Fixed by #60

Comments

@mwarkentin
Copy link

mwarkentin commented May 26, 2023

Not sure if I've never tried this before, or if Slack just changed something, but recently I copied a link to a message within a thread (I didn't care about anything before it in the thread) and using this link on gh-slack didn't work:

❯ gh slack --limit=1000 https://*****.slack.com/archives/C0220QQNUHE/p1684440714803369?thread_ts=1684440607.895759&cid=C0220QQNUHE | pbcopy
[1] 24189
zsh: no matches found: https://*****.slack.com/archives/C0220QQNUHE/p1684440714803369?thread_ts=1684440607.895759
[1]  + exit 1     gh slack --limit=1000

When I grabbed the first message in the thread the URL didn't have the query params and worked:

❯ gh slack --limit=1000 https://*****.slack.com/archives/C0220QQNUHE/p1684440714803369 | pbcopy

Ideally this would grab the contents of the thread starting from that point, but I'd also be ok if it just ignored the query params and pulled the whole thread.

@rneatherway
Copy link
Owner

Hey @mwarkentin, just got back from a trip. The only case I am completely sure that gh-slack works in is when reading a whole thread. Reading a partial thread (your case) or reading a unthreaded messages from a channel both have oddities.

That being said, I think to test properly you need to quote the URL because it contains an ampersand. Right now it's being interpreted by zsh as a request to background the gh slack invocation (hence [1] 24189). This happens to me with curl pretty regularly when I forget to quote the URL.

@mwarkentin
Copy link
Author

I'll try that and let you know, thanks!

@mwarkentin
Copy link
Author

Only took me 9 months, but I tried it with quotes and doesn't seem to help :D

states/base/files on  master [?] via 🐍 v3.11.7 (.ops-venv) on ☁️  [email protected](us-central1)
❯ gh slack --limit=1000 'https://sentry.slack.com/archives/C06MA1ST3B5/p1709648390444389?thread_ts=1709320542.716369&cid=C06MA1ST3B5'

states/base/files on  master [?] via 🐍 v3.11.7 (.ops-venv) on ☁️  [email protected](us-central1)

@rneatherway
Copy link
Owner

rneatherway commented Mar 6, 2024

Hi @mwarkentin, I think the issue is down to the parsing of the permalink. Here is an example link for the first message in a thread:

https://sanity-io-land.slack.com/archives/C9Y51FDGA/p1709663536325529

No query parameters!

One for the third message in a thread:

https://sanity-io-land.slack.com/archives/C9Y51FDGA/p1709664320730949?thread_ts=1709663536.325529&cid=C9Y51FDGA

This code doesn't look at the query parameters at all:

// https://github.slack.com/archives/CP9GMKJCE/p1648028606962719
// returns (github, CP9GMKJCE, 1648028606.962719, nil)
func parsePermalink(link string) (linkParts, error) {
result := permalinkRE.FindStringSubmatch(link)
if result == nil {
return linkParts{}, fmt.Errorf("not a permalink: %q", link)
}
return linkParts{
team: result[1],
channelID: result[2],
timestamp: result[3] + "." + result[4],
}, nil
}

That means that it's the same as just requesting all the top level messages in the channel after the time of the original message in the thread.

I think just using the thread_ts query parameter if it exists would fix the issue. You can validate that by trying:

gh slack api get conversations.replies -f channel=C06MA1ST3B5 -f ts=1709320542.716369

and seeing if the expected messages come out.

@rneatherway
Copy link
Owner

@mwarkentin I've put together a fix, which was a little more complicated than I thought, over at #60. Could you give it a try please? If you check out that PR then you can run:

go run ./cmd/gh-slack/ --limit=1000 'https://sentry.slack.com/archives/C06MA1ST3B5/p1709648390444389?thread_ts=1709320542.716369&cid=C06MA1ST3B5'

@mwarkentin
Copy link
Author

@rneatherway thanks! I will try to give that a shot tomorrow!

@mwarkentin
Copy link
Author

Confirmed fixed over here: #60 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants