Apply channel_name_template to 1-to-1 DM rooms; track displayname template hash to force re-sync on change#74
Open
BierDav wants to merge 5 commits intomautrix:mainfrom
Conversation
…e changes Co-authored-by: BierDav <46626041+BierDav@users.noreply.github.com>
Co-authored-by: BierDav <46626041+BierDav@users.noreply.github.com>
…ame_template Co-authored-by: BierDav <46626041+BierDav@users.noreply.github.com>
…tals Co-authored-by: BierDav <46626041+BierDav@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: This code was fully AI generated, but reviewed by me if makes sense. I'm not an expert in go nor very familiar with the codebase. I've tested these changes in my environment using the follwing configuration:
Two independent bugs prevented templates from being applied as configured:
DM rooms bypassed
channel_name_template— room name was leftnil, so the Matrix bridge used the ghost display name directly. Users had no way to add a suffix (e.g.(SL)) to DM rooms independently of puppet names.Changing
displayname_templatedidn't re-format existing puppets — the bridge uses Slack's incremental cache API (GetUsersCacheContextwith per-user timestamps). If a user's Slack profile hadn't changed, Slack returned nothing,wrapUserInfowas never called, and the new template was never applied.Changes
DM room names now go through
channel_name_templateroomType != database.RoomTypeDMguard inwrapChatInfo;formatChannelNameis now called unconditionally for all channel types.info.Nameis already set to the other user's ghost display name, so the default template is fully backward-compatible.example-config.yamlto document that.Namefor DM channels is the other user's display name.Template-change detection forces puppet re-sync
NameTemplateHash(string,omitempty) toGhostMetadata— persisted in the DB, records which template version last formatted each ghost.Configcomputes a 16-hex-char SHA-256 hash ofDisplaynameTemplateat load time; exposed viaGetDisplaynameTemplateHash().wrapUserInfoExtraUpdateswrites the current hash into ghost metadata after formatting.syncManyUserspasseslastUpdated = 0for any ghost whose stored hash diverges from the current one, forcing Slack to return full user data even for otherwise-unchanged profiles.GetUserInfobypasses the 4-hourMinGhostSyncIntervalgate when the template hash has changed.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.