Expose public/ API as submodule (#23345)
* model -> public/model * plugin -> public/plugin * public/model/utils -> public/utils * platform/shared/mlog -> public/shared/mlog * platform/shared/i18n -> public/shared/i18n * platform/shared/markdown -> public/shared/markdown * platform/services/timezones -> public/shared/timezones * channels/einterfaces -> einterfaces * expose public/ submodule * go mod tidy * .github: cache-dependency-path, setup-go-work * modules-tidy for public/ too * remove old gomodtidy
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
070ee26081
Коммит
bb02b35048
56
server/public/model/member_invite.go
Обычный файл
56
server/public/model/member_invite.go
Обычный файл
@@ -0,0 +1,56 @@
|
||||
// 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]interface{} {
|
||||
return map[string]interface{}{
|
||||
"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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user