party로 그룹 변경
This commit is contained in:
@ -1,43 +1,55 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
)
|
||||
|
||||
type groupConfig struct {
|
||||
UniqueIndex []string `json:"unique_index"`
|
||||
SearchIndex []string `json:"search_index"`
|
||||
MemberIndex []string `json:"member_index"`
|
||||
TextSearchFields []string `json:"text_search_field"`
|
||||
InviteExpire int32 `json:"invite_ttl"` // 그룹이 개인에게 보낸 초대장 만료 기한
|
||||
CandidateExpire int32 `json:"candidate_ttl"` // 개인이 그룹에게 보낸 신청서 만료 기한
|
||||
InviteeExlusive bool `json:"invitee_exlusive"`
|
||||
InviteeIsMember bool `json:"invitee_is_member"`
|
||||
MaxMember int `json:"max_member"`
|
||||
Transient bool `json:"transient"`
|
||||
var groupTypes map[string]reflect.Type
|
||||
|
||||
Name string
|
||||
func groupTypeContainer() map[string]reflect.Type {
|
||||
if groupTypes == nil {
|
||||
groupTypes = make(map[string]reflect.Type)
|
||||
}
|
||||
return groupTypes
|
||||
}
|
||||
|
||||
type apiFuncType func(http.ResponseWriter, *http.Request)
|
||||
type apiFuncsContainer struct {
|
||||
normfuncs map[string]apiFuncType
|
||||
funcs map[string][]apiFuncType
|
||||
}
|
||||
|
||||
func (afc *apiFuncsContainer) registApiFunction(name string, f apiFuncType) {
|
||||
afc.funcs[name] = append(afc.funcs[name], f)
|
||||
}
|
||||
|
||||
func (afc *apiFuncsContainer) normalize() {
|
||||
for k, v := range afc.funcs {
|
||||
if len(v) == 1 {
|
||||
afc.normfuncs[k] = v[0]
|
||||
} else {
|
||||
afc.normfuncs[k] = func(w http.ResponseWriter, r *http.Request) {
|
||||
for _, f := range v {
|
||||
f(w, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
afc.funcs = nil
|
||||
}
|
||||
|
||||
func (afc *apiFuncsContainer) call(fn string, w http.ResponseWriter, r *http.Request) {
|
||||
f := afc.normfuncs[fn]
|
||||
if f != nil {
|
||||
f(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
type configDocument map[string]any
|
||||
type group interface {
|
||||
Create(form url.Values, doc bson.M) (primitive.ObjectID, error)
|
||||
Candidate(groupID primitive.ObjectID, memberID primitive.ObjectID, doc bson.M) error
|
||||
Join(groupID primitive.ObjectID, memberID primitive.ObjectID, doc bson.M) error
|
||||
Invite(groupID primitive.ObjectID, memberID primitive.ObjectID, inviterDoc bson.M, inviteeDoc bson.M) (string, error)
|
||||
CancelInvitation(groupID primitive.ObjectID, ticketID primitive.ObjectID) error
|
||||
AcceptInvitation(groupID primitive.ObjectID, mid primitive.ObjectID, member bson.M) error
|
||||
DenyInvitation(groupID primitive.ObjectID, mid primitive.ObjectID, ticketID primitive.ObjectID) error
|
||||
QueryInvitations(memberID primitive.ObjectID, after primitive.Timestamp) ([]bson.M, error)
|
||||
Exist(groupID primitive.ObjectID, filter bson.M) (bool, error)
|
||||
FindAll(filter bson.M, projection string, after primitive.Timestamp) ([]bson.M, error)
|
||||
FindOne(groupID primitive.ObjectID, projection string) (bson.M, error)
|
||||
Leave(groupID primitive.ObjectID, memberID primitive.ObjectID) error
|
||||
UpdateMemberDocument(groupID primitive.ObjectID, memberID primitive.ObjectID, doc bson.M) error
|
||||
Dismiss(groupID primitive.ObjectID) error
|
||||
UpdateGroupDocument(groupID primitive.ObjectID, doc bson.M) error
|
||||
QueryGroupMembers(groupID primitive.ObjectID) (bson.M, error)
|
||||
MemberDisconnected(room string, mid primitive.ObjectID)
|
||||
Initialize(*subTavern, configDocument) error
|
||||
ClientMessageReceved(*wshandler.Sender, wshandler.WebSocketMessageType, any)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user