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

Use zulip topic permalinks #1826

Open
RalfJung opened this issue Jul 14, 2024 · 3 comments
Open

Use zulip topic permalinks #1826

RalfJung opened this issue Jul 14, 2024 · 3 comments
Labels
A-zulip Area: Zulip integration

Comments

@RalfJung
Copy link
Member

When generating links to Zulip topics, currently the link changes when the topic gets renamed. With zulip/zulip#21505 Zulip has topic permalinks; ideally the bot would use those so that the link remains stable even if the topic gets renamed (e.g. when it gets "marked as resolved").

@Mark-Simulacrum
Copy link
Member

Is there a link/description of the link syntax? Skimming that issue I didn't see an obvious description.

triagebot/src/zulip.rs

Lines 356 to 376 in 989e03c

Recipient::Stream { id, topic } => {
// See
// https://github.com/zulip/zulip/blob/46247623fc279/zerver/lib/url_encoding.py#L9
// ALWAYS_SAFE without `.` from
// https://github.com/python/cpython/blob/113e2b0a07c/Lib/urllib/parse.py#L772-L775
//
// ALWAYS_SAFE doesn't contain `.` because Zulip actually encodes them to be able
// to use `.` instead of `%` in the encoded strings
const ALWAYS_SAFE: &str =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-~";
let mut encoded_topic = String::new();
for ch in topic.bytes() {
if !(ALWAYS_SAFE.contains(ch as char)) {
write!(encoded_topic, ".{:02X}", ch).unwrap();
} else {
encoded_topic.push(ch as char);
}
}
format!("stream/{}-xxx/topic/{}", id, encoded_topic)
}
is where we generate the URLs I think, so that's what would need updating.

@timabbott
Copy link

The syntax involves #narrow/channel/{channel_id}/topic/{encoded_topic}/with/{anchor_message_id}. It's not available in Zulip Cloud yet (ETA: 1-2 weeks), so you can't use it yet.

We are still working through some bugs and then documenting it, and are not currently making use of it because we want to wait until mobile clients upgrade, since while the latest mobile apps support it, the links will not function for folks whose phones haven't updated yet. So we probably won't make the markdown processor generate them for **stream>topic** syntax for a few weeks after we make the server/web app start support processing them to wait for clients to upgrade, but we'd be excited to have folks test and shake out any bugs.

@timabbott
Copy link

https://chat.zulip.org/api/construct-narrow#narrows-that-use-ids has v0 API docs already available, but we're planning to rewrite those over the next couple of days to be nicer.

@ehuss ehuss added the A-zulip Area: Zulip integration label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-zulip Area: Zulip integration
Projects
None yet
Development

No branches or pull requests

4 participants