diff --git a/server/db/mysql/tenant_groups.go b/server/db/mysql/tenant_groups.go index f6aa82e..7d9670a 100644 --- a/server/db/mysql/tenant_groups.go +++ b/server/db/mysql/tenant_groups.go @@ -930,6 +930,24 @@ func (a *adapter) TenantGroupMuteList(id t.TenantID, topic, cursor string, limit return items, next, rows.Err() } +func (a *adapter) TenantGroupMuteGet(id t.TenantID, topic string, uid t.Uid) (*t.GroupMute, error) { + if tenantAdp, err := a.routeGroupTenant(id); err != nil { + return nil, err + } else if tenantAdp != a { + return tenantAdp.TenantGroupMuteGet(id, topic, uid) + } + if topic == "" || uid.IsZero() { + return nil, t.ErrMalformed + } + now := time.Now().UTC() + ctx, cancel := a.getContext() + if cancel != nil { + defer cancel() + } + return a.groupMuteByQuery(ctx, "SELECT "+groupMuteSelectColumns+" FROM im_group_mutes WHERE topic=? AND user_id=? AND status=? AND (expires_at IS NULL OR expires_at>?)", + topic, decodeUID(uid), t.GroupMuteStatusActive, now) +} + func (a *adapter) TenantGroupMuteUpsert(id t.TenantID, mute *t.GroupMute) (*t.GroupMute, error) { if tenantAdp, err := a.routeGroupTenant(id); err != nil { return nil, err