Closed JulienTant closed 5 months ago
@lieut-data we do have this migration that runs everytime if the plugin has a remoteID:
func (s *SQLStore) runMigrationRemoteID(remoteID string) error {
_, err := s.getQueryBuilder().Update("Users").Set("RemoteID", remoteID).Where(sq.And{
sq.NotEq{"RemoteID": nil},
sq.NotEq{"RemoteID": ""},
sq.Expr("RemoteID NOT IN (SELECT remoteid FROM remoteclusters)"),
sq.Like{"Username": "msteams_%"},
}).Exec()
return err
}
So anyone with a msteams_
name, that has a RemoteID AND this RemoteID is NOT part of remoteclusters
will be assigned the plugin RemoteID. So in theory, every restart of the plugin """fixes""" the existing users.
Summary
When creating a synthetic user from a DM/GM, we set a remoteID based on the user UUID instead of using the plugin remoteID.
Example of how it's done for the syncUsers job: https://github.com/mattermost/mattermost-plugin-msteams/blob/main/server/plugin.go#L727
Ticket Link
https://mattermost.atlassian.net/browse/MM-57568