Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

Commit

Permalink
Upgraded to latest aero version
Browse files Browse the repository at this point in the history
  • Loading branch information
akyoto committed Jun 1, 2019
1 parent 95adc59 commit 1feee3c
Show file tree
Hide file tree
Showing 37 changed files with 133 additions and 162 deletions.
12 changes: 6 additions & 6 deletions AMVAPI.go
Expand Up @@ -42,7 +42,7 @@ func init() {
}

// Create sets the data for a new AMV with data we received from the API request.
func (amv *AMV) Create(ctx *aero.Context) error {
func (amv *AMV) Create(ctx aero.Context) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand All @@ -61,22 +61,22 @@ func (amv *AMV) Create(ctx *aero.Context) error {
}

// Edit creates an edit log entry.
func (amv *AMV) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (amv *AMV) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(amv, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (amv *AMV) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (amv *AMV) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(amv, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (amv *AMV) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (amv *AMV) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(amv, ctx, key, index, obj)
}

// DeleteInContext deletes the amv in the given context.
func (amv *AMV) DeleteInContext(ctx *aero.Context) error {
func (amv *AMV) DeleteInContext(ctx aero.Context) error {
user := GetUserFromContext(ctx)

// Write log entry
Expand Down Expand Up @@ -117,7 +117,7 @@ func (amv *AMV) Delete() error {
}

// Authorize returns an error if the given API POST request is not authorized.
func (amv *AMV) Authorize(ctx *aero.Context, action string) error {
func (amv *AMV) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand Down
8 changes: 4 additions & 4 deletions ActivityConsumeAnimeAPI.go
Expand Up @@ -15,7 +15,7 @@ var (
)

// Authorize returns an error if the given API POST request is not authorized.
func (activity *ActivityConsumeAnime) Authorize(ctx *aero.Context, action string) error {
func (activity *ActivityConsumeAnime) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand All @@ -35,7 +35,7 @@ func (activity *ActivityConsumeAnime) Save() {
}

// DeleteInContext deletes the activity in the given context.
func (activity *ActivityConsumeAnime) DeleteInContext(ctx *aero.Context) error {
func (activity *ActivityConsumeAnime) DeleteInContext(ctx aero.Context) error {
return activity.Delete()
}

Expand Down Expand Up @@ -64,7 +64,7 @@ func (activity *ActivityConsumeAnime) Delete() error {
// }

// // Authorize returns an error if the given API request is not authorized.
// func (activity *Activity) Authorize(ctx *aero.Context, action string) error {
// func (activity *Activity) Authorize(ctx aero.Context, action string) error {
// user := GetUserFromContext(ctx)

// if user == nil {
Expand All @@ -75,6 +75,6 @@ func (activity *ActivityConsumeAnime) Delete() error {
// }

// // DeleteInContext deletes the activity in the given context.
// func (activity *Activity) DeleteInContext(ctx *aero.Context) error {
// func (activity *Activity) DeleteInContext(ctx aero.Context) error {
// return activity.Delete()
// }
4 changes: 2 additions & 2 deletions AnalyticsAPI.go
Expand Up @@ -12,12 +12,12 @@ var (
)

// Authorize returns an error if the given API POST request is not authorized.
func (analytics *Analytics) Authorize(ctx *aero.Context, action string) error {
func (analytics *Analytics) Authorize(ctx aero.Context, action string) error {
return AuthorizeIfLoggedIn(ctx)
}

// Create creates a new analytics object.
func (analytics *Analytics) Create(ctx *aero.Context) error {
func (analytics *Analytics) Create(ctx aero.Context) error {
body, err := ctx.Request().Body().Bytes()

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions AnimeAPI.go
Expand Up @@ -36,7 +36,7 @@ func init() {
}

// Edit creates an edit log entry.
func (anime *Anime) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (anime *Anime) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
user := GetUserFromContext(ctx)

if key == "Status" {
Expand Down Expand Up @@ -71,17 +71,17 @@ func (anime *Anime) Edit(ctx *aero.Context, key string, value reflect.Value, new
}

// OnAppend saves a log entry.
func (anime *Anime) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (anime *Anime) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(anime, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (anime *Anime) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (anime *Anime) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(anime, ctx, key, index, obj)
}

// Authorize returns an error if the given API POST request is not authorized.
func (anime *Anime) Authorize(ctx *aero.Context, action string) error {
func (anime *Anime) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil || (user.Role != "editor" && user.Role != "admin") {
Expand All @@ -92,7 +92,7 @@ func (anime *Anime) Authorize(ctx *aero.Context, action string) error {
}

// DeleteInContext deletes the anime in the given context.
func (anime *Anime) DeleteInContext(ctx *aero.Context) error {
func (anime *Anime) DeleteInContext(ctx aero.Context) error {
user := GetUserFromContext(ctx)

// Write log entry
Expand Down
2 changes: 1 addition & 1 deletion AnimeCharacterAPI.go
Expand Up @@ -11,7 +11,7 @@ var (
)

// Create sets the data for new anime characters.
func (character *AnimeCharacter) Create(ctx *aero.Context) error {
func (character *AnimeCharacter) Create(ctx aero.Context) error {
character.Role = "supporting"
return nil
}
8 changes: 4 additions & 4 deletions AnimeCharactersAPI.go
Expand Up @@ -17,7 +17,7 @@ var (
)

// Authorize returns an error if the given API POST request is not authorized.
func (characters *AnimeCharacters) Authorize(ctx *aero.Context, action string) error {
func (characters *AnimeCharacters) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil || (user.Role != "editor" && user.Role != "admin") {
Expand All @@ -28,17 +28,17 @@ func (characters *AnimeCharacters) Authorize(ctx *aero.Context, action string) e
}

// Edit creates an edit log entry.
func (characters *AnimeCharacters) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (characters *AnimeCharacters) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(characters, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (characters *AnimeCharacters) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (characters *AnimeCharacters) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(characters, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (characters *AnimeCharacters) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (characters *AnimeCharacters) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(characters, ctx, key, index, obj)
}

Expand Down
8 changes: 4 additions & 4 deletions AnimeEpisodesAPI.go
Expand Up @@ -17,7 +17,7 @@ var (
)

// Authorize returns an error if the given API POST request is not authorized.
func (episodes *AnimeEpisodes) Authorize(ctx *aero.Context, action string) error {
func (episodes *AnimeEpisodes) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil || (user.Role != "editor" && user.Role != "admin") {
Expand All @@ -28,17 +28,17 @@ func (episodes *AnimeEpisodes) Authorize(ctx *aero.Context, action string) error
}

// Edit creates an edit log entry.
func (episodes *AnimeEpisodes) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (episodes *AnimeEpisodes) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(episodes, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (episodes *AnimeEpisodes) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (episodes *AnimeEpisodes) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(episodes, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (episodes *AnimeEpisodes) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (episodes *AnimeEpisodes) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(episodes, ctx, key, index, obj)
}

Expand Down
2 changes: 1 addition & 1 deletion AnimeListAPI.go
Expand Up @@ -23,7 +23,7 @@ func init() {
}

// Authorize returns an error if the given API request is not authorized.
func (list *AnimeList) Authorize(ctx *aero.Context, action string) error {
func (list *AnimeList) Authorize(ctx aero.Context, action string) error {
return AuthorizeIfLoggedInAndOwnData(ctx, "id")
}

Expand Down
4 changes: 2 additions & 2 deletions AnimeListItemAPI.go
Expand Up @@ -17,7 +17,7 @@ var (
)

// Edit ...
func (item *AnimeListItem) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (bool, error) {
func (item *AnimeListItem) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (bool, error) {
user := GetUserFromContext(ctx)

if user == nil {
Expand Down Expand Up @@ -88,7 +88,7 @@ func (item *AnimeListItem) Edit(ctx *aero.Context, key string, value reflect.Val
}

// AfterEdit is called after the item is edited.
func (item *AnimeListItem) AfterEdit(ctx *aero.Context) error {
func (item *AnimeListItem) AfterEdit(ctx aero.Context) error {
item.Rating.Clamp()
item.Edited = DateTimeUTC()
return nil
Expand Down
8 changes: 4 additions & 4 deletions AnimeRelationsAPI.go
Expand Up @@ -17,7 +17,7 @@ var (
)

// Authorize returns an error if the given API POST request is not authorized.
func (relations *AnimeRelations) Authorize(ctx *aero.Context, action string) error {
func (relations *AnimeRelations) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil || (user.Role != "editor" && user.Role != "admin") {
Expand All @@ -28,17 +28,17 @@ func (relations *AnimeRelations) Authorize(ctx *aero.Context, action string) err
}

// Edit creates an edit log entry.
func (relations *AnimeRelations) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (relations *AnimeRelations) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(relations, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (relations *AnimeRelations) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (relations *AnimeRelations) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(relations, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (relations *AnimeRelations) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (relations *AnimeRelations) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(relations, ctx, key, index, obj)
}

Expand Down
4 changes: 2 additions & 2 deletions AuthorizeHelper.go
Expand Up @@ -8,7 +8,7 @@ import (

// AuthorizeIfLoggedInAndOwnData authorizes the given request if a user is logged in
// and the user ID matches the ID in the request.
func AuthorizeIfLoggedInAndOwnData(ctx *aero.Context, userIDParameterName string) error {
func AuthorizeIfLoggedInAndOwnData(ctx aero.Context, userIDParameterName string) error {
err := AuthorizeIfLoggedIn(ctx)

if err != nil {
Expand All @@ -25,7 +25,7 @@ func AuthorizeIfLoggedInAndOwnData(ctx *aero.Context, userIDParameterName string
}

// AuthorizeIfLoggedIn authorizes the given request if a user is logged in.
func AuthorizeIfLoggedIn(ctx *aero.Context) error {
func AuthorizeIfLoggedIn(ctx aero.Context) error {
if !ctx.HasSession() {
return errors.New("Neither logged in nor in session")
}
Expand Down
12 changes: 6 additions & 6 deletions CharacterAPI.go
Expand Up @@ -38,7 +38,7 @@ func init() {
}

// Create sets the data for a new character with data we received from the API request.
func (character *Character) Create(ctx *aero.Context) error {
func (character *Character) Create(ctx aero.Context) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand All @@ -57,7 +57,7 @@ func (character *Character) Create(ctx *aero.Context) error {
}

// Authorize returns an error if the given API request is not authorized.
func (character *Character) Authorize(ctx *aero.Context, action string) error {
func (character *Character) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand All @@ -77,22 +77,22 @@ func (character *Character) Authorize(ctx *aero.Context, action string) error {
}

// Edit creates an edit log entry.
func (character *Character) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (character *Character) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(character, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (character *Character) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (character *Character) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(character, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (character *Character) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (character *Character) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(character, ctx, key, index, obj)
}

// DeleteInContext deletes the character in the given context.
func (character *Character) DeleteInContext(ctx *aero.Context) error {
func (character *Character) DeleteInContext(ctx aero.Context) error {
user := GetUserFromContext(ctx)

// Write log entry
Expand Down
4 changes: 2 additions & 2 deletions ClientErrorReportAPI.go
Expand Up @@ -12,7 +12,7 @@ var (
)

// Create sets the data for a new report with data we received from the API request.
func (report *ClientErrorReport) Create(ctx *aero.Context) error {
func (report *ClientErrorReport) Create(ctx aero.Context) error {
data, err := ctx.Request().Body().JSONObject()

if err != nil {
Expand Down Expand Up @@ -45,7 +45,7 @@ func (report *ClientErrorReport) Save() {
}

// Authorize returns an error if the given API request is not authorized.
func (report *ClientErrorReport) Authorize(ctx *aero.Context, action string) error {
func (report *ClientErrorReport) Authorize(ctx aero.Context, action string) error {
if action == "create" {
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions CompanyAPI.go
Expand Up @@ -37,7 +37,7 @@ func init() {
}

// Create sets the data for a new company with data we received from the API request.
func (company *Company) Create(ctx *aero.Context) error {
func (company *Company) Create(ctx aero.Context) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand All @@ -57,17 +57,17 @@ func (company *Company) Create(ctx *aero.Context) error {
}

// Edit creates an edit log entry.
func (company *Company) Edit(ctx *aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
func (company *Company) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
return edit(company, ctx, key, value, newValue)
}

// OnAppend saves a log entry.
func (company *Company) OnAppend(ctx *aero.Context, key string, index int, obj interface{}) {
func (company *Company) OnAppend(ctx aero.Context, key string, index int, obj interface{}) {
onAppend(company, ctx, key, index, obj)
}

// OnRemove saves a log entry.
func (company *Company) OnRemove(ctx *aero.Context, key string, index int, obj interface{}) {
func (company *Company) OnRemove(ctx aero.Context, key string, index int, obj interface{}) {
onRemove(company, ctx, key, index, obj)
}

Expand All @@ -77,7 +77,7 @@ func (company *Company) Save() {
}

// DeleteInContext deletes the company in the given context.
func (company *Company) DeleteInContext(ctx *aero.Context) error {
func (company *Company) DeleteInContext(ctx aero.Context) error {
user := GetUserFromContext(ctx)

// Write log entry
Expand Down Expand Up @@ -124,7 +124,7 @@ func (company *Company) Delete() error {
}

// Authorize returns an error if the given API request is not authorized.
func (company *Company) Authorize(ctx *aero.Context, action string) error {
func (company *Company) Authorize(ctx aero.Context, action string) error {
user := GetUserFromContext(ctx)

if user == nil {
Expand Down
2 changes: 1 addition & 1 deletion ExternalMediaAPI.go
Expand Up @@ -11,7 +11,7 @@ var (
)

// Create sets the data for new external media.
func (media *ExternalMedia) Create(ctx *aero.Context) error {
func (media *ExternalMedia) Create(ctx aero.Context) error {
media.Service = "Youtube"
return nil
}

0 comments on commit 1feee3c

Please sign in to comment.