Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
79 lines
2.7 KiB
Go
79 lines
2.7 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package properties
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
)
|
|
|
|
func (ps *PropertyService) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
|
return ps.fieldStore.Create(field)
|
|
}
|
|
|
|
func (ps *PropertyService) GetPropertyField(groupID, id string) (*model.PropertyField, error) {
|
|
return ps.fieldStore.Get(groupID, id)
|
|
}
|
|
|
|
func (ps *PropertyService) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
|
return ps.fieldStore.GetMany(groupID, ids)
|
|
}
|
|
|
|
func (ps *PropertyService) GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
|
return ps.fieldStore.GetFieldByName(groupID, targetID, name)
|
|
}
|
|
|
|
func (ps *PropertyService) CountActivePropertyFieldsForGroup(groupID string) (int64, error) {
|
|
return ps.fieldStore.CountForGroup(groupID, false)
|
|
}
|
|
|
|
func (ps *PropertyService) CountAllPropertyFieldsForGroup(groupID string) (int64, error) {
|
|
return ps.fieldStore.CountForGroup(groupID, true)
|
|
}
|
|
|
|
func (ps *PropertyService) CountActivePropertyFieldsForTarget(groupID, targetType, targetID string) (int64, error) {
|
|
return ps.fieldStore.CountForTarget(groupID, targetType, targetID, false)
|
|
}
|
|
|
|
func (ps *PropertyService) CountAllPropertyFieldsForTarget(groupID, targetType, targetID string) (int64, error) {
|
|
return ps.fieldStore.CountForTarget(groupID, targetType, targetID, true)
|
|
}
|
|
|
|
func (ps *PropertyService) SearchPropertyFields(groupID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
|
// groupID is part of the search method signature to
|
|
// incentivize the use of the database indexes in searches
|
|
opts.GroupID = groupID
|
|
|
|
return ps.fieldStore.SearchPropertyFields(opts)
|
|
}
|
|
|
|
func (ps *PropertyService) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
|
fields, err := ps.UpdatePropertyFields(groupID, []*model.PropertyField{field})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return fields[0], nil
|
|
}
|
|
|
|
func (ps *PropertyService) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
|
return ps.fieldStore.Update(groupID, fields)
|
|
}
|
|
|
|
func (ps *PropertyService) DeletePropertyField(groupID, id string) error {
|
|
// if groupID is not empty, we need to check first that the field belongs to the group
|
|
if groupID != "" {
|
|
if _, err := ps.GetPropertyField(groupID, id); err != nil {
|
|
return fmt.Errorf("error getting property field %q for group %q: %w", id, groupID, err)
|
|
}
|
|
}
|
|
|
|
if err := ps.valueStore.DeleteForField(groupID, id); err != nil {
|
|
return err
|
|
}
|
|
|
|
return ps.fieldStore.Delete(groupID, id)
|
|
}
|