Read-mentions “mark all”, link-entity creation, logout cleanup, and read-model sync#43
Read-mentions “mark all”, link-entity creation, logout cleanup, and read-model sync#43AliKhadivi wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
When extracting MessageEntity, what issues couldn't be handled before the modification, and what problems were fixed after it? Could you list some examples?
There was a problem hiding this comment.
🧩 Summary of Fixes in MessageAppService.cs
Before:
- URL detection was basic — only matched
https://..., missed schemeless links, IPs, and ports. - URLs sometimes merged or included punctuation (like
example.com).). - Mentions (
@user) were falsely detected inside emails or URLs. - Hashtags accepted digits or underscores as first char, no length limit.
- Bot commands (
/create image) marked entire message, not just/create. - Duplicate URL logic appeared in multiple classes.
After (Fixes & Improvements):
-
Unified & Strong URL Regex
- Handles
http/https, schemeless (example.com), IPv4, and ports. - Skips trailing punctuation and clamps overly long URLs.
- Caps TLD length (rejects invalid domains like
ofd.registrarpersonid). - Prevents overlapping/merged URL entities.
- Handles
-
Centralized Entity Extraction
- All entity detection (URL, mention, hashtag, bot command) happens in
MessageAppService— no duplication in handlers.
- All entity detection (URL, mention, hashtag, bot command) happens in
-
Safer Mentions
- Ignores
@gmailin emails and@userinside URLs.
- Ignores
-
Improved Hashtags
- Regex:
#[A-Za-z][A-Za-z0-9_]{0,254} - Must start with a letter; max length = 256 characters.
- Regex:
-
Stricter Bot Command Parsing
/commandlimited to[A-Za-z0-9_]and ≤ 64 chars (so/create image→ only/create).
-
Consistent Invite Link Preview
- Moved invite URL detection into a reusable method (
CreateInvitePreviewIfAnyAsync) inside the service.
- Moved invite URL detection into a reusable method (
✅ Result:
Message entities (URLs, mentions, hashtags, commands) are now parsed correctly, bounded, and non-overlapping — giving Telegram-accurate behavior, better safety, and zero duplication between service and handler.
|
The current PR changes too many things. Could you make each PR address only one issue and submit them separately? |
|
|
||
| return new TAffectedHistory | ||
| { | ||
| Pts = ptsHelper.GetCachedPts(input.UserId), |
There was a problem hiding this comment.
If executing the command requires modifying pts, you may need to create a new XXXSaga to handle it. After incrementing pts, publish a DomainEvent, then return the result to the client in the DomainEventHandler. You can refer to EditMessageSaga/ClearHistorySaga as an example.
Signed-off-by: Ali Khadivi <74895885+AliKhadivi@users.noreply.github.com>
- ReadMentionCommand, ReadMentionCommandHandler, MentionReadEvent: Removed (refactored in dev) - DialogAggregate, handlers: Kept dev version (architecture evolved) - Note: PR loyldg#43 was 4+ months old with 721 commits divergence - ReadMentions feature still partially available through updated handlers - Manual merge required due to significant architecture changes
ReadMention(messageId, bool readAllMentions); command/handler updated;messages.readMentionsnow clears all unread mentions.MessageAppService.^/…length), invite preview via service, channel initialviews = 0, one-shot draft clear.LogOutEventHandlerunregisters device auth keys onUserLoggedOutEvent.DialogReadModeltracks mention create/read;MessageReadModelupdatesViews.Notes: Interface changes to
IMessageAppServiceandIUsernameHelper;ReadMentionCommandaddsreadAllMentions.