Skip to content
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

MM-58437: support notifications alongside channel sync #674

Merged
merged 14 commits into from
May 29, 2024

Conversation

lieut-data
Copy link
Member

Summary

Allow normal channel sync alongside notifications. Sync of chats and group chats remains disabled when notifications are enabled.

Ticket Link

Fixes: https://mattermost.atlassian.net/browse/MM-58437

@lieut-data lieut-data added the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label May 28, 2024
@@ -558,9 +558,9 @@ func getUpdatedMessage(teamID, channelID, parentID, msteamsID string, client mst
func (p *Plugin) ShouldSyncDMGMChannel(channel *model.Channel) bool {
switch channel.Type {
case model.ChannelTypeDirect:
return p.getConfiguration().SyncDirectMessages
return p.GetSyncDirectMessages()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the helper functions, since they now interpolate whether or not notifications are enabled to decide if we should sync direct messages.

Comment on lines -27 to -31
// Ignore two-way sync when notifications are enabled.
if p.GetSyncNotifications() {
return
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShouldSyncDMGMChannel handles this for us now.

"github.com/mattermost/mattermost/server/public/model"
)

// mockTeams is an abstraction over directly mocking the client calls made by the plugin to instead
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another new experiment: most of the time, I don't actually /care/ about the function calls, just want to get the side effects. This streamlines that step. If it works, I'll extend this and make it part of the other tests that aren't explicitly testing function calls in the same way.

func (mth *mockTeamsHelper) registerChat(chatID string, users []*model.User) {
var members []clientmodels.ChatMember
for _, user := range users {
mth.registerUser(user)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically teach the mock about the user!

}, nil).Maybe()
}

func (mth *mockTeamsHelper) registerGroupChat(chatID string, users []*model.User) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated making this "smart" based on the number of users, but figured I'd keep it 1:1 with the return values for now.

@lieut-data lieut-data added this to the v1.14 milestone May 28, 2024
Copy link
Member

@JulienTant JulienTant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -122,11 +122,11 @@ func (p *Plugin) GetSyncNotifications() bool {
}

func (p *Plugin) GetSyncDirectMessages() bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not part of this PR pre se but I'd like to have those renamed to something more accurate.

Base automatically changed from mm-58439-remove-automute-and-teams-primary to main May 28, 2024 21:55
@lieut-data lieut-data removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label May 29, 2024
@lieut-data lieut-data merged commit 1c8ec95 into main May 29, 2024
9 checks passed
@lieut-data lieut-data deleted the mm-58437-support-notifications-alongside-channel-sync branch May 29, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants