mattermost-community-enterp.../public/model/member_invite.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
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>
2025-12-17 23:59:07 +09:00

57 lines
1.3 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
import (
"encoding/json"
"net/http"
)
type MemberInvite struct {
Emails []string `json:"emails"`
ChannelIds []string `json:"channelIds,omitempty"`
Message string `json:"message"`
}
func (i *MemberInvite) Auditable() map[string]any {
return map[string]any{
"emails": i.Emails,
"channel_ids": i.ChannelIds,
}
}
// IsValid validates that the invitation info is loaded correctly and with the correct structure
func (i *MemberInvite) IsValid() *AppError {
if len(i.Emails) == 0 {
return NewAppError("MemberInvite.IsValid", "model.member.is_valid.emails.app_error", nil, "", http.StatusBadRequest)
}
if len(i.ChannelIds) > 0 {
for _, channel := range i.ChannelIds {
if len(channel) != 26 {
return NewAppError("MemberInvite.IsValid", "model.member.is_valid.channel.app_error", nil, "channel="+channel, http.StatusBadRequest)
}
}
}
return nil
}
func (i *MemberInvite) UnmarshalJSON(b []byte) error {
var emails []string
if err := json.Unmarshal(b, &emails); err == nil {
*i = MemberInvite{}
i.Emails = emails
return nil
}
type TempMemberInvite MemberInvite
var o2 TempMemberInvite
if err := json.Unmarshal(b, &o2); err != nil {
return err
}
*i = MemberInvite(o2)
return nil
}