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

Renaming a stream does not preserve links #4713

Closed
jmandel opened this issue May 8, 2017 · 10 comments
Closed

Renaming a stream does not preserve links #4713

jmandel opened this issue May 8, 2017 · 10 comments

Comments

@jmandel
Copy link
Contributor

jmandel commented May 8, 2017

One of the amazing things about renaming a github repo, or moving a github repo to a different organization, is that old links (web links + git remotes) keep working after the transition.

It would be delightful if Zulip did something similar when streams were renamed. My expectation is that if you renamed a stream A to B, visiting /#narrow/stream/A would redirect to /#narrow/stream/B. If someone then re-created a new A, the redirect would no longer apply.

I don't have a good sense of how challenging this would be to implement :-)

@zulipbot
Copy link
Member

zulipbot commented May 8, 2017

Hello @zulip/server-streams members, this issue was labeled with the area: stream settings label, so you may want to check it out!

@lonerz
Copy link
Member

lonerz commented May 8, 2017

What would happen when some other streams takes the old name of the other stream?

@jmandel
Copy link
Contributor Author

jmandel commented May 8, 2017

Wow, thanks for the quick feedback! I described this case in the issue:

If someone then re-created a new A, the redirect would no longer apply.

Does this make sense?

@lonerz
Copy link
Member

lonerz commented May 8, 2017

Ah, missed that part. Makes sense 👍

@timabbott
Copy link
Member

The default strategy I'd probably take with this is the same that we currently use for PM threads, basically putting the ID of the object into the URL:

https://chat.zulip.org/#narrow/pm-with/857-joshuapan8

So we'd be doing here e.g.

https://chat.zulip.org/#narrow/stream/123125-A

I don't think that change would be super difficult to implement. Downsides include:
(1) If you're writing documentation or something, you can't just enter a permanent link by typing the URl structure from memory, you need to actually go grab it from the Zulip UI so you get the stream ID.
(2) the change would probably break all existing links, unless we're going to ban names starting with "[0-9]+-" from the space of valid stream names, so that one can parse both formats. In which case, I suppose we could support the sloppy form of links as well; they just wouldn't have the benefits of surviving a stream rename.

Thoughts? I think that this model is probably simpler than making a StreamAlias table that contains redirects from old stream names to new ones, at the cost of making the URLs somewhat less attractive.

@jmandel
Copy link
Contributor Author

jmandel commented May 8, 2017

Thanks @timabbott ! I should have read this earlier :-)

the change would probably break all existing links

Yeah, that's the part that breaks my use case (preserving historical links from the FHIR issue tracker, mailing list, etc). I wound up taking a naive stab at something more like the StreamAlias, mostly as an exercise in (re)familiarizing myself with the codebase.

There are challenging bits that I haven't tried, like updating the client-side rename list when stream names change while the client is running (thought it's vaguely possible this works correctly, given that the server-side tests pass). My sense is it's probably less work to throw this out and start something new (since 95% of my effort was understanding the codebase), but not sure whether I'll have the time for it.

I'll send along a PR for what's there.

@jmandel
Copy link
Contributor Author

jmandel commented May 9, 2017

OK, now that I have some tests in place and have figured out where to hook the logic into the frontend, I'm much happier with this. If it's getting close enough to be at all plausible for inclusion in 1.6 @timabbott that'd be awesome (but otherwise we can always deploy in FHIR's fork).

@showell
Copy link
Contributor

showell commented May 11, 2017

I think this is a bit ambitious to get into 1.6, which we're hoping to release pretty soon.

I definitely like some of the ideas here:

  • We should persist old names with something like StreamAlias, as shown in your PR. We'll want to make absolutely sure there's a DB index on the name field.
  • On the client side we can have a simple mapping of old_stream_name -> stream_id, and we can try to find the most surgical places to swap in the "current" name for things like filtering.
  • We can fix the hashes to include stream id like we did with PMs--I think this will largely solve the problem of somebody posting a link on a blog or similar that gets out of date due to a rename.

We should probably discuss this on chat.

@timabbott
Copy link
Member

I like the last solution.

showell pushed a commit to showell/zulip that referenced this issue Feb 19, 2018
This commit prefixes stream names in urls with stream ids,
so that the urls don't break when we rename streams.

strean name: foo bar.com%
before: #narrow/stream/foo.20bar.2Ecom.25
after: #narrow/stream/20-foo-bar.2Ecom.25

For new realms, everything is simple under the new scheme, since
we just parse out the stream id every time to figure out where
to narrow.

For old realms, any old URLs will still work under the new scheme,
assuming the stream hasn't been renamed (and of course old urls
wouldn't have survived stream renaming in the first place).  The one
exception is the hopefully rare case of a stream name starting with
something like "99-" and colliding with another stream whose id is 99.

The way that we enocde the stream name portion of the URL is kind
of unimportant now, since we really only look at the stream id, but
we still want a safe encoding of the name that is mostly human
readable, so we now convert spaces to dashes in the stream name.  Also,
we try to ensure more code on both sides (frontend and backend) calls
common functions to do the encoding.

Fixes zulip#4713
@timabbott
Copy link
Member

@jmandel well, this took longer than might have been ideal to happen, but I'm pretty happy with the solution in #8400. Thanks again for bringing this issue to our attention! :)

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

No branches or pull requests

5 participants