-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Short links #544
Short links #544
Conversation
3eab565
to
6554ea0
Compare
44358fc
to
ae6669e
Compare
0468ed4
to
e497690
Compare
app/support/backlinks.ts
Outdated
@@ -16,6 +16,11 @@ export function extractUUIDs(text: string | null): UUID[] { | |||
return text ? [...text.matchAll(uuidRe)].map((m) => m[0]).filter(onlyUnique) : []; | |||
} | |||
|
|||
export const shortLinkRe = /\/[A-Za-z0-9]{3,25}\/([0-9a-f]{6,10})/gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут ещё надо минус учесть, для groupnames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И не надо ли границу слов как-то проверять? А то оно и в посторонних урлах может сработать. Или понадеемся, что 6 символов с нашими id-ами вряд ли совпадут?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут непонятно. С одной стороны, мы вроде как хотели всю эту логику на клиент отдать. С другой стороны, из-за бэклинков вот приходится делать парсинг на сервере. Надо бы как-то формализовать это, чтоб алгоритм на сервере и клиенте — ну, не совпадали, но хоть как-то были близки.
Или не париться, потому что к большому беспорядку false positives не приведут…
63ca674
to
38aba98
Compare
2f8ac64
to
abf46f7
Compare
We define short_comment_id as two characters of the UUID, followed by the hex-encoded seq_number.
This change adds parsing of short comment links (e.g. `/user/9bac13#ad2b`) to EventService a.k.a Notifications. That is the only place we need special support. Other relevant server parts (backlinks table, reindex script, realtime events) only need the post_id anyway (for now), so they work with such links already, not caring about the comment_id part.
Before: - generate shortId on READ - use 2 chars of UUID followed by seqNumber (resulting length is 3+) After: - generate shortId on WRITE, and put into table `comments` (column `short_id`) - use randomly generated hex string (resulting length is 4-6)
38dc55d
to
ea7805b
Compare
This is the server-side part of the Short Links feature.
shortId
prop to Post objects in API responsesGET /v2/posts/:postId
) to accept post's short ID along with the long IDPart 2: