Skip to content

Commit

Permalink
Massive Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 committed Oct 5, 2024
1 parent da31edf commit f03bffe
Show file tree
Hide file tree
Showing 30 changed files with 1,095 additions and 85 deletions.
5 changes: 4 additions & 1 deletion cmd/api/external/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func main() {
_ = godotenv.Load(".env")
config.Cfg = config.New()

oauth.OAuthConfig = oauth.Initialize(config.Cfg)
log.SetLevel(log.DebugLevel)

oauth.OAuthConfig = oauth.InitializeVATSIM(config.Cfg)
oauth.DiscordOAuthConfig = oauth.InitializeDiscord(config.Cfg)

bucket, err := storage.NewS3Client(config.Cfg.S3)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {
_ = godotenv.Load(".env")
config.Cfg = config.New()

oauth.OAuthConfig = oauth.Initialize(config.Cfg)
oauth.OAuthConfig = oauth.InitializeVATSIM(config.Cfg)

bucket, err := storage.NewS3Client(config.Cfg.S3)
if err != nil {
Expand Down
23 changes: 22 additions & 1 deletion cmd/database/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func MigrateFacilities(oldDbConn *gorm.DB) {
oldDbConn.Table("facilities").Find(&facilities)

for _, facility := range facilities {
if facility.ID == "PCF" {
continue
}

newFacility := &models.Facility{
ID: constants.FacilityID(facility.ID),
Name: facility.Name,
Expand Down Expand Up @@ -170,10 +174,27 @@ func MigrateUsers(oldDbConn *gorm.DB) {
continue
}

// Create User Notification Settings
userNotificationSettings := &models.UserNotification{
CID: user.CID,
DiscordEnabled: true,
EmailEnabled: true,
Events: true,
Training: true,
Feedback: true,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}

if err := userNotificationSettings.Create(); err != nil {
fmt.Printf("Error creating user notification settings: %s\n", err.Error())
continue
}

// 3. Migrate user roster
roster := &models.Roster{
CID: user.CID,
Facility: constants.FacilityID(user.HomeFacility),
Facility: user.HomeFacility,
CreatedAt: user.JoinDate,
OIs: newUser.PreferredOIs,
Home: true,
Expand Down
175 changes: 169 additions & 6 deletions external/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2622,6 +2622,113 @@ const docTemplate = `{
}
}
},
"/user/{cid}/notification-settings": {
"get": {
"description": "Get a user notification settings",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"notification-settings"
],
"summary": "Get a user notification settings",
"parameters": [
{
"type": "integer",
"description": "CID",
"name": "cid",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/user_notification.Response"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
}
}
},
"put": {
"description": "Update a user notification settings",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"notification-settings"
],
"summary": "Update a user's notifications settings",
"parameters": [
{
"type": "integer",
"description": "CID",
"name": "cid",
"in": "path",
"required": true
},
{
"description": "Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user_notification.Request"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/user_notification.Response"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/utils.ErrResponse"
}
}
}
}
},
"/user/{cid}/notification/{id}": {
"put": {
"description": "Update a notification",
Expand Down Expand Up @@ -3871,7 +3978,7 @@ const docTemplate = `{
"required": [
"callsign",
"controller_cid",
"notes",
"feedback",
"pilot_cid",
"position",
"rating",
Expand All @@ -3890,7 +3997,7 @@ const docTemplate = `{
"type": "integer",
"example": 1293257
},
"notes": {
"feedback": {
"type": "string",
"example": "Raaj was the best controller I've ever flown under."
},
Expand Down Expand Up @@ -3955,14 +4062,14 @@ const docTemplate = `{
],
"example": "ZDV"
},
"feedback": {
"type": "string",
"example": "Raaj was the best controller I've ever flown under."
},
"id": {
"type": "integer",
"example": 1
},
"notes": {
"type": "string",
"example": "Raaj was the best controller I've ever flown under."
},
"position": {
"type": "string",
"example": "DEN_I_APP"
Expand Down Expand Up @@ -4326,6 +4433,9 @@ const docTemplate = `{
],
"example": "ZDV"
},
"first_name": {
"type": "string"
},
"home": {
"type": "boolean",
"example": true
Expand All @@ -4334,6 +4444,9 @@ const docTemplate = `{
"type": "integer",
"example": 1
},
"last_name": {
"type": "string"
},
"operating_initials": {
"type": "string",
"example": "RP"
Expand Down Expand Up @@ -4673,6 +4786,56 @@ const docTemplate = `{
}
}
},
"user_notification.Request": {
"type": "object",
"properties": {
"discord": {
"type": "boolean",
"example": true
},
"email": {
"type": "boolean",
"example": true
},
"events": {
"type": "boolean",
"example": true
},
"feedback": {
"type": "boolean",
"example": true
},
"training": {
"type": "boolean",
"example": true
}
}
},
"user_notification.Response": {
"type": "object",
"properties": {
"discord": {
"type": "boolean",
"example": true
},
"email": {
"type": "boolean",
"example": true
},
"events": {
"type": "boolean",
"example": true
},
"feedback": {
"type": "boolean",
"example": true
},
"training": {
"type": "boolean",
"example": true
}
}
},
"user_role.Request": {
"type": "object",
"required": [
Expand Down
Loading

0 comments on commit f03bffe

Please sign in to comment.