Skip to content

Commit a7ee943

Browse files
author
Matrix-X
committed
add(openWork): add EventChangeAppAdmin for type InfoTypeChangeAppAdmin
1 parent 0933ce4 commit a7ee943

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/openWork/server/models/event.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
type InfoType = string
13+
type EventType = string
1314

1415
const (
1516
InfoTypeSuiteTicket InfoType = "suite_ticket"
@@ -23,9 +24,10 @@ const (
2324
InfoTypeCorpArchAuth InfoType = "corp_arch_auth"
2425
InfoTypeApproveSpecialAuth InfoType = "approve_special_auth"
2526
InfoTypeCancelSpecialAuth InfoType = "cancel_special_auth"
26-
InfoTypeChangeAppAdmin InfoType = "change_app_admin"
2727
)
2828

29+
const EventTypeChangeAppAdmin EventType = "change_app_admin"
30+
2931
type ChangeType = string
3032

3133
const (
@@ -87,7 +89,14 @@ func (ev BaseEvent) GetTimestamp() int64 {
8789
}
8890

8991
func (msg BaseEvent) ToEvent() (IEvent, error) {
90-
switch msg.GetInfoType() {
92+
infoType := msg.GetInfoType()
93+
if infoType == "" {
94+
if msg.Event == EventTypeChangeAppAdmin {
95+
return new(EventChangeAppAdmin), nil
96+
}
97+
return nil, errors.New(string(msg.Event))
98+
}
99+
switch infoType {
91100
case InfoTypeSuiteTicket:
92101
return new(EventSuiteTicket), nil
93102
case InfoTypeCreateAuth:
@@ -115,8 +124,6 @@ func (msg BaseEvent) ToEvent() (IEvent, error) {
115124
return new(EventCorpArchAuth), nil
116125
case InfoTypeApproveSpecialAuth, InfoTypeCancelSpecialAuth:
117126
return new(EventSpecialAuth), nil
118-
case InfoTypeChangeAppAdmin:
119-
return new(EventChangeAppAdmin), nil
120127
default:
121128
return nil, errors.New("unknown event")
122129
}

0 commit comments

Comments
 (0)