We do a lot of things when joining a thread so it made more sense to use already created logic for this. If the link secret is provided, we're checking link validity instead of permissions and based on the result continue with the process. This implementation has small issue, because it is possible that e.g. server crashes between adding someone to a thread and reporting link usage. This is a really unlikely corner case, which probably can be fixed by using transactions (there might be some other solutions, but probably complicated). At this point we're not handling link expiration, so I'll take a look at the solutions while implementing the remaining part.
Depends on D7525