-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
167 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package constants | ||
|
||
var ( | ||
FacilityTierOne = map[FacilityID][]FacilityID{ | ||
AlbuquerqueFacility: { | ||
LosAngelesFacility, | ||
DenverFacility, | ||
KansasCityFacility, | ||
FortWorthFacility, | ||
HoustonFacility, | ||
}, | ||
LosAngelesFacility: { | ||
OaklandFacility, | ||
SaltLakeFacility, | ||
DenverFacility, | ||
AlbuquerqueFacility, | ||
HonoluluFacility, | ||
}, | ||
OaklandFacility: { | ||
SeattleFacility, | ||
SaltLakeFacility, | ||
LosAngelesFacility, | ||
HonoluluFacility, | ||
}, | ||
SeattleFacility: { | ||
AnchorageFacility, | ||
SaltLakeFacility, | ||
OaklandFacility, | ||
HonoluluFacility, | ||
}, | ||
HonoluluFacility: { | ||
AnchorageFacility, | ||
SeattleFacility, | ||
OaklandFacility, | ||
LosAngelesFacility, | ||
}, | ||
DenverFacility: { | ||
SaltLakeFacility, | ||
MinneapolisFacility, | ||
KansasCityFacility, | ||
AlbuquerqueFacility, | ||
LosAngelesFacility, | ||
}, | ||
HoustonFacility: { | ||
AlbuquerqueFacility, | ||
FortWorthFacility, | ||
MemphisFacility, | ||
JacksonvilleFacility, | ||
}, | ||
|
||
//TODO - finish me | ||
} | ||
) | ||
|
||
func (a FacilityID) IsTierOne(b FacilityID) bool { | ||
for _, fac := range FacilityTierOne[a] { | ||
if fac == b { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package vatsim_api | ||
|
||
type User struct { | ||
CID string `json:"cid"` | ||
Personal struct { | ||
FirstName string `json:"name_first"` | ||
LastName string `json:"name_last"` | ||
FullName string `json:"name_full"` | ||
Email string `json:"email"` | ||
} `json:"personal"` | ||
VATSIM struct { | ||
ControllerRating struct { | ||
ID int `json:"id"` | ||
Short string `json:"short"` | ||
Long string `json:"long"` | ||
} `json:"rating"` | ||
PilotRating struct { | ||
ID int `json:"id"` | ||
Short string `json:"short"` | ||
Long string `json:"long"` | ||
} `json:"pilotrating"` | ||
Region struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
} `json:"region"` | ||
Division struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
} `json:"division"` | ||
Subdivision struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
} `json:"subdivision"` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package vatsim_webhooks | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
) | ||
|
||
type Message struct { | ||
CID uint `json:"resource"` | ||
Actions []Action `json:"actions"` | ||
} | ||
|
||
type WebhookActionType string | ||
|
||
const ( | ||
UserCreation WebhookActionType = "member_created_action" | ||
UserChanged WebhookActionType = "member_changed_action" | ||
) | ||
|
||
type Action struct { | ||
Type WebhookActionType `json:"action"` | ||
Authority string `json:"authority"` | ||
Comment string `json:"comment"` | ||
Deltas []Delta `json:"deltas"` | ||
Timestamp time.Time `json:"timestamp"` | ||
} | ||
|
||
type Delta struct { | ||
Field string `json:"field"` | ||
Before string `json:"before"` | ||
After string `json:"after"` | ||
} | ||
|
||
// TODO - does user creation webhook only send to VATUSA if they select division_id = USA? | ||
// TODO - Rating changes? if VATUSA is the authority its not gonna send the webhook back to VATUSA correct? or it will? | ||
func ConsumeMessage(rawMessage string) error { | ||
msg := Message{} | ||
if err := json.Unmarshal([]byte(rawMessage), &msg); err != nil { | ||
return err | ||
} | ||
|
||
for _, action := range msg.Actions { | ||
switch action.Type { | ||
case UserCreation: | ||
// | ||
case UserChanged: | ||
// | ||
default: | ||
// TODO - log unknown actionType | ||
|
||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func HandleUserCreation(action Action) error { | ||
return nil | ||
} | ||
|
||
func HandleUserChange(action Action) error { | ||
return nil | ||
} |