mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
The server module named github.com/hanzoai/team/server/v8 — a path that resolves to the retired workspace's repository, not this one — while server/public still published github.com/mattermost/mattermost/server/public. Both are github.com/hanzoteam/server/... now, which is where this code actually lives. That second half is what made the binary unbootable. Upstream's public path stayed claimed by upstream, mattermost-plugin-ai imported it, and the build linked public/model twice; public/plugin's gob.Register then ran twice under one name and panicked at init, before main. Reverting the rename traded the brand for a working binary. Rebranding the plugin alongside it needs no such trade: the agents fork is github.com/hanzoteam/agents/v2 against our public module, so no module named mattermost/mattermost is in the graph at all. Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and it is ours.
58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package sharedchannel
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanzoteam/server/server/public/model"
|
|
"github.com/hanzoteam/server/server/public/shared/mlog"
|
|
)
|
|
|
|
func (scs *Service) isChannelMemberSyncEnabled() bool {
|
|
return scs.server.GetRemoteClusterService() != nil
|
|
}
|
|
|
|
// NotifyMembershipChanged is called when users are added or removed from a shared channel.
|
|
// It triggers a sync for the channel so that membership changes are picked up from
|
|
// ChannelMemberHistory at sync time, following the same pattern as posts and reactions.
|
|
// originRemoteID identifies the remote that initiated the change, so it can be skipped
|
|
// during sync to prevent echo-back.
|
|
func (scs *Service) NotifyMembershipChanged(channelID string, originRemoteID string) {
|
|
if !scs.isChannelMemberSyncEnabled() {
|
|
return
|
|
}
|
|
task := newSyncTask(channelID, "", "", nil, nil)
|
|
task.originRemoteID = originRemoteID
|
|
task.schedule = time.Now().Add(NotifyMinimumDelay)
|
|
scs.addTask(task)
|
|
}
|
|
|
|
// ForceMembershipSyncForRemote triggers a sync for all channels shared with the specified remote.
|
|
// Called when a remote comes back online to catch up on any membership changes that occurred
|
|
// while it was offline. The sync pipeline will read ChannelMemberHistory using the
|
|
// LastMembersSyncAt cursor to detect both additions and removals.
|
|
func (scs *Service) ForceMembershipSyncForRemote(rc *model.RemoteCluster) {
|
|
if !scs.isChannelMemberSyncEnabled() {
|
|
return
|
|
}
|
|
|
|
opts := model.SharedChannelRemoteFilterOpts{
|
|
RemoteId: rc.RemoteId,
|
|
}
|
|
scrs, err := scs.server.GetStore().SharedChannel().GetRemotes(0, 999999, opts)
|
|
if err != nil {
|
|
scs.server.Log().LogM(mlog.MlvlSharedChannelServiceError, "Failed to fetch shared channel remotes for membership sync",
|
|
mlog.String("remote", rc.DisplayName),
|
|
mlog.String("remoteId", rc.RemoteId),
|
|
mlog.Err(err),
|
|
)
|
|
return
|
|
}
|
|
|
|
for _, scr := range scrs {
|
|
scs.NotifyChannelChanged(scr.ChannelId)
|
|
}
|
|
}
|