mirror of
https://github.com/discourse/discourse.git
synced 2025-04-22 10:39:11 +08:00

Followup b5147a4634f0fd5c98262f949a8c766bfd73d290 When we aliased `leave` to `remove` and renamed the method in `DirectMessageChannel` in the previous commit, this inadvertantly caused an error when unfollowing group channels in the channel list. When clicking the X in the channel list, we hit ChannelsCurrentUserMembershipFollowsController for the current user and the channel, which is supposed to only unfollow the channel for all channel types including DMs. Group DMs have a different Leave behaviour vs Unfollow. Leaving the channel altogether is done from the channel settings page, the "Leave channel" button, and that deletes the user's membership and DM user record from that channel. So, we were trying to do the leave channel behaviour in the unfollow channel controller, which was returning the wrong record for the serializer (a User not a Membership) This fixes the issue and removes a bit of delegate/alias indirection which was making the code a bit harder to fllow and search, even though it was more succinct. Also adds missing specs that would have caught this regression.