Deleted utils.GetUser

This commit is contained in:
Eduard Urbach 2019-11-17 16:59:34 +09:00
parent ad9870b1c1
commit daed4146ed
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
117 changed files with 178 additions and 271 deletions

View File

@ -166,3 +166,20 @@ func SortUsersFollowers(users []*User) map[string]int {
return followCount
}
// SameUser returns true or false depending on if the users are the same.
func SameUser(a *User, b *User) bool {
if a == nil {
return false
}
if b == nil {
return false
}
if a.ID == b.ID {
return true
}
return false
}

View File

@ -11,7 +11,6 @@ import (
"github.com/aerogo/log"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils"
jsoniter "github.com/json-iterator/go"
"golang.org/x/oauth2"
"golang.org/x/oauth2/facebook"
@ -100,7 +99,7 @@ func Facebook(app *aero.Application, authLog *log.Log) {
fbUser.Email = strings.Replace(fbUser.Email, "googlemail.com", "gmail.com", 1)
// Is this an existing user connecting another social account?
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user != nil {
// Add FacebookToUser reference

View File

@ -11,7 +11,6 @@ import (
"github.com/aerogo/log"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils"
jsoniter "github.com/json-iterator/go"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
@ -111,7 +110,7 @@ func Google(app *aero.Application, authLog *log.Log) {
googleUser.Email = strings.Replace(googleUser.Email, "googlemail.com", "gmail.com", 1)
// Is this an existing user connecting another social account?
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user != nil {
// Add GoogleToUser reference

View File

@ -5,7 +5,7 @@ import (
"github.com/aerogo/aero"
"github.com/aerogo/log"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/arn"
)
// Logout is called when the user clicks the logout button.
@ -13,7 +13,7 @@ import (
func Logout(app *aero.Application, authLog *log.Log) {
app.Get("/logout", func(ctx aero.Context) error {
if ctx.HasSession() {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user != nil {
authLog.Info("%s logged out | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName())

View File

@ -12,7 +12,6 @@ import (
"github.com/aerogo/log"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils"
"github.com/gomodule/oauth1/oauth"
jsoniter "github.com/json-iterator/go"
)
@ -112,7 +111,7 @@ func Twitter(app *aero.Application, authLog *log.Log) {
twUser.Email = strings.Replace(twUser.Email, "googlemail.com", "gmail.com", 1)
// Is this an existing user connecting another social account?
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user != nil {
// Add TwitterToUser reference

View File

@ -9,7 +9,7 @@ import (
"github.com/aerogo/aero"
"github.com/aerogo/log"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/arn"
)
var (
@ -54,7 +54,7 @@ func logRequest(ctx aero.Context, responseTime time.Duration) {
responseTimeString = strings.Repeat(" ", repeatSpaceCount) + responseTimeString
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
ip := ctx.IP()
hostNames, cached := GetHostsForIP(ip)

View File

@ -9,7 +9,6 @@ import (
"github.com/aerogo/http/client"
"github.com/akyoto/color"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
"github.com/mssola/user_agent"
)
@ -25,7 +24,7 @@ func UserInfo(next aero.Handler) aero.Handler {
return nil
}
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
// When there's no user logged in, nothing to update
if user == nil {

View File

@ -30,7 +30,7 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
if item.Status != arn.AnimeListStatusCompleted
.anime-list-item-episodes
.anime-list-item-episodes-watched
.action(contenteditable=utils.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes
.action(contenteditable=arn.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes
if item.Status == arn.AnimeListStatusWatching && user != nil && user.ID == viewUser.ID
.plus-episode.action(data-action="increaseEpisode", data-trigger="click") +
@ -41,4 +41,4 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
.anime-list-item-episodes-max= item.Anime().EpisodeCountString()
.anime-list-item-rating-container
.anime-list-item-rating.action.tip(contenteditable=utils.SameUser(user, viewUser), data-field="Rating.Overall", data-type="number", data-trigger="focusout", data-action="save", aria-label="O: " + utils.FormatRating(item.Rating.Overall) + " | S: " + utils.FormatRating(item.Rating.Story) + " | V: " + utils.FormatRating(item.Rating.Visuals) + " | M: " + utils.FormatRating(item.Rating.Soundtrack))= utils.FormatRating(item.Rating.Overall)
.anime-list-item-rating.action.tip(contenteditable=arn.SameUser(user, viewUser), data-field="Rating.Overall", data-type="number", data-trigger="focusout", data-action="save", aria-label="O: " + utils.FormatRating(item.Rating.Overall) + " | S: " + utils.FormatRating(item.Rating.Story) + " | V: " + utils.FormatRating(item.Rating.Visuals) + " | M: " + utils.FormatRating(item.Rating.Soundtrack))= utils.FormatRating(item.Rating.Overall)

View File

@ -3,19 +3,18 @@ package activity
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
)
// Global activity page.
func Global(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
activities := fetchActivities(user, false)
return render(ctx, activities)
}
// Followed activity page.
func Followed(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
activities := fetchActivities(user, true)
return render(ctx, activities)
}

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -15,7 +14,7 @@ const (
// render renders the activities page with the given activities.
func render(ctx aero.Context, allActivities []arn.Activity) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
// Slice the part that we need

View File

@ -6,8 +6,8 @@ import (
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/host"
@ -16,7 +16,7 @@ import (
// Get admin page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect(http.StatusTemporaryRedirect, "/")

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// PaymentHistory ...
func PaymentHistory(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// PurchaseHistory ...
func PurchaseHistory(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -13,7 +13,7 @@ import (
// UserRegistrations ...
func UserRegistrations(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -7,14 +7,13 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Get a single AMV.
func Get(ctx aero.Context) error {
id := ctx.Get("id")
amv, err := arn.GetAMV(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "AMV not found", err)

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
@ -14,7 +13,7 @@ import (
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
amv, err := arn.GetAMV(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "AMV not found", err)

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -15,7 +14,7 @@ const (
// render renders the AMVs page with the given AMVs.
func render(ctx aero.Context, allAMVs []*arn.AMV) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
tag := ctx.Get("tag")

View File

@ -9,7 +9,6 @@ import (
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
const (
@ -22,7 +21,7 @@ const (
// Get anime page.
func Get(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
anime, err := arn.GetAnime(id)
if err != nil {

View File

@ -3,8 +3,6 @@ package anime
import (
"net/http"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
@ -14,7 +12,7 @@ import (
// Characters ...
func Characters(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
anime, err := arn.GetAnime(id)
if err != nil {

View File

@ -4,7 +4,6 @@ import (
"net/http"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
@ -12,7 +11,7 @@ import (
// Comments ...
func Comments(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
anime, err := arn.GetAnime(id)

View File

@ -6,14 +6,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
// Main anime edit page.
func Main(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
@ -31,7 +30,7 @@ func Main(ctx aero.Context) error {
// Images anime images edit page.
func Images(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
@ -49,7 +48,7 @@ func Images(ctx aero.Context) error {
// Characters anime characters edit page.
func Characters(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
@ -73,7 +72,7 @@ func Characters(ctx aero.Context) error {
// Relations anime relations edit page.
func Relations(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
@ -97,7 +96,7 @@ func Relations(ctx aero.Context) error {
// Episodes anime episodes edit page.
func Episodes(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")

View File

@ -4,7 +4,6 @@ import (
"net/http"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
@ -12,7 +11,7 @@ import (
// Episodes ...
func Episodes(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
anime, err := arn.GetAnime(id)
episodeToFriends := map[int][]*arn.User{}

View File

@ -6,12 +6,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Relations ...
func Relations(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
anime, err := arn.GetAnime(id)

View File

@ -3,8 +3,6 @@ package anime
import (
"net/http"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
@ -14,7 +12,7 @@ import (
// Tracks ...
func Tracks(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
anime, err := arn.GetAnime(id)

View File

@ -6,7 +6,6 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
// DeleteKitsu marks an anime for deletion.
@ -14,7 +13,7 @@ func DeleteKitsu(ctx aero.Context) error {
id := ctx.Get("id")
// Is the user allowed to delete?
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -10,13 +10,12 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
// Kitsu anime import.
func Kitsu(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -9,7 +9,6 @@ import (
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -20,7 +19,7 @@ const (
// Filter filters a user's anime list item by the status.
func Filter(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
status := ctx.Get("status")
sortBy := arn.SortByRating

View File

@ -4,13 +4,13 @@ import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// DeleteConfirmation shows the confirmation page before deleting an anime list.
func DeleteConfirmation(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")
@ -21,7 +21,7 @@ func DeleteConfirmation(ctx aero.Context) error {
// Delete deletes your entire anime list.
func Delete(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -4,12 +4,12 @@ import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/arn"
)
// Redirect to the full URL including the user nick.
func Redirect(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get anime page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)

View File

@ -23,7 +23,7 @@ var weekdayNames = []string{
// Get renders the calendar page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
oneWeek := 7 * 24 * time.Hour
now := time.Now()

View File

@ -19,7 +19,7 @@ const (
// Get character.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
character, err := arn.GetCharacter(id)

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
@ -14,7 +13,7 @@ import (
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
character, err := arn.GetCharacter(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Character not found", err)
@ -27,7 +26,7 @@ func Edit(ctx aero.Context) error {
func EditImages(ctx aero.Context) error {
id := ctx.Get("id")
character, err := arn.GetCharacter(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Character not found", err)

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -15,7 +14,7 @@ const (
// render renders the characters page with the given characters.
func render(ctx aero.Context, allCharacters []*arn.Character) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
tag := ctx.Get("tag")

View File

@ -3,15 +3,14 @@ package charge
import (
"net/http"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get charge page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -8,12 +8,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// All renders an index of all companies.
func All(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
companies := arn.FilterCompanies(func(company *arn.Company) bool {
return !company.IsDraft

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -12,7 +11,7 @@ const maxPopularCompanies = 10
// Popular renders the best companies.
func Popular(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
// Fetch all eligible companies

View File

@ -14,7 +14,7 @@ import (
// Get renders a company page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
company, err := arn.GetCompany(id)

View File

@ -8,7 +8,6 @@ import (
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
@ -16,7 +15,7 @@ import (
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
company, err := arn.GetCompany(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Company not found", err)

View File

@ -13,7 +13,7 @@ import (
// AnimeList ...
func AnimeList(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
nickA := ctx.Get("nick-1")
nickB := ctx.Get("nick-2")

View File

@ -9,7 +9,6 @@ import (
"github.com/animenotifier/notify.moe/utils/infinitescroll"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
const (
@ -19,7 +18,7 @@ const (
// Get edit log.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
nick := ctx.Get("nick")

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect(http.StatusTemporaryRedirect, "/")

View File

@ -7,14 +7,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxAnimeEntries = 70
// editorList renders the anime list with the given title and filter.
func editorList(ctx aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -6,14 +6,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxEntries = 70
// NoDescription ...
func NoDescription(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect(http.StatusTemporaryRedirect, "/")

View File

@ -7,14 +7,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxSoundTrackEntries = 70
// editorList renders the soundtrack list with the given title and filter.
func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -4,6 +4,7 @@ import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
@ -30,7 +31,7 @@ var jobLogs = []string{}
// Overview shows all background jobs.
func Overview(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
jobs := []*utils.JobInfo{}
for _, job := range jobInfo {

View File

@ -7,7 +7,6 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
// Only allow one job to be started at a time
@ -18,7 +17,7 @@ func Start(ctx aero.Context) error {
jobStartMutex.Lock()
defer jobStartMutex.Unlock()
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not authorized")

View File

@ -7,12 +7,11 @@ import (
"github.com/animenotifier/kitsu"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// NewKitsuAnime ...
func NewKitsuAnime(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
finder := arn.NewAnimeFinder("kitsu/anime")
deletedIDs, err := arn.GetIDList("deleted kitsu anime")

View File

@ -19,7 +19,7 @@ type diffFunction func(*arn.Anime, *mal.Anime) []animediff.Difference
// CompareMAL ...
func CompareMAL(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
year := ctx.Get("year")
status := ctx.Get("status")
season := ctx.Get("season")

View File

@ -4,13 +4,13 @@ import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get anime list in the browser extension.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.HTML(components.Login("_blank"))

View File

@ -7,13 +7,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
minio "github.com/minio/minio-go/v6"
)
// Get renders the anime episode.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
// Get episode

View File

@ -7,7 +7,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Filter filters the anime for the explore page.
@ -16,7 +15,7 @@ func Filter(ctx aero.Context) error {
season := ctx.Get("season")
status := ctx.Get("status")
typ := ctx.Get("type")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
now := time.Now()
if year == "" {

View File

@ -8,7 +8,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -19,7 +18,7 @@ const (
// AnimeByAverageColor returns all anime with an image in the given color.
func AnimeByAverageColor(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
color := ctx.Get("color")
index, _ := ctx.GetInt("index")

View File

@ -14,7 +14,7 @@ import (
// Sequels ...
func Sequels(ctx aero.Context) error {
nick := ctx.Get("nick")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
viewUser, err := arn.GetUserByNick(nick)
if err != nil {

View File

@ -14,7 +14,7 @@ const minYear = 1963
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
maxYear := time.Now().Year() - 1
hallOfFameEntries := []*utils.HallOfFameEntry{}

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const animePerPage = 100
@ -14,7 +13,7 @@ const animeRatingCountThreshold = 5
// Get renders the genre page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
genreName := ctx.Get("name")
animes := []*arn.Anime{}

View File

@ -4,12 +4,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
genres := []string{}
genreToAnime := map[string]*arn.Anime{}

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
@ -14,7 +13,7 @@ import (
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
group, err := arn.GetGroup(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Group not found", err)
@ -33,7 +32,7 @@ func Edit(ctx aero.Context) error {
func EditImage(ctx aero.Context) error {
id := ctx.Get("id")
group, err := arn.GetGroup(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Group not found", err)

View File

@ -7,12 +7,11 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Feed shows the group front page.
func Feed(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
group, err := arn.GetGroup(id)

View File

@ -7,12 +7,11 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Info shows the group information page.
func Info(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
group, err := arn.GetGroup(id)

View File

@ -7,12 +7,11 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Members shows the group members.
func Members(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
group, err := arn.GetGroup(id)

View File

@ -4,14 +4,13 @@ import (
"net/http"
"sort"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
)
// Joined shows the most popular joined groups.
func Joined(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -15,7 +14,7 @@ const (
// render renders the groups page with the given groups.
func render(ctx aero.Context, allGroups []*arn.Group) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
// Slice the part that we need

View File

@ -2,13 +2,14 @@ package home
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/pages/frontpage"
"github.com/animenotifier/notify.moe/utils"
)
// Get the anime list or the frontpage when logged out.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return frontpage.Get(ctx)

View File

@ -8,12 +8,11 @@ import (
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
// Get inventory page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
viewUser := user
if user == nil {

View File

@ -4,13 +4,13 @@ import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")

View File

@ -10,12 +10,11 @@ import (
"github.com/animenotifier/anilist"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Preview shows an import preview.
func Preview(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -32,7 +31,7 @@ func Preview(ctx aero.Context) error {
// Finish ...
func Finish(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -74,7 +73,7 @@ func Finish(ctx aero.Context) error {
// getMatches finds and returns all matches for the logged in user.
func getMatches(ctx aero.Context) ([]*arn.AniListMatch, error) {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return nil, errors.New("Not logged in")

View File

@ -9,12 +9,11 @@ import (
"github.com/animenotifier/kitsu"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Preview shows an import preview.
func Preview(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -31,7 +30,7 @@ func Preview(ctx aero.Context) error {
// Finish ...
func Finish(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -85,7 +84,7 @@ func Finish(ctx aero.Context) error {
// getMatches finds and returns all matches for the logged in user.
func getMatches(ctx aero.Context) ([]*arn.KitsuMatch, error) {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return nil, errors.New("Not logged in")

View File

@ -10,12 +10,11 @@ import (
"github.com/animenotifier/mal"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Preview shows an import preview.
func Preview(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -32,7 +31,7 @@ func Preview(ctx aero.Context) error {
// Finish ...
func Finish(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -79,7 +78,7 @@ func Finish(ctx aero.Context) error {
// getMatches finds and returns all matches for the logged in user.
func getMatches(ctx aero.Context) ([]*arn.MyAnimeListMatch, error) {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return nil, errors.New("Not logged in")

View File

@ -2,12 +2,12 @@ package me
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/arn"
)
// Get ...
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.JSON(nil)

View File

@ -4,13 +4,13 @@ import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get forums page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")

View File

@ -8,12 +8,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils"
)
// CountUnseen sends the number of unseen notifications.
func CountUnseen(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -26,7 +25,7 @@ func CountUnseen(ctx aero.Context) error {
// MarkNotificationsAsSeen marks all notifications as seen.
func MarkNotificationsAsSeen(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")
@ -73,7 +72,7 @@ func Latest(ctx aero.Context) error {
// Test sends a test notification to the logged in user.
func Test(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")

View File

@ -8,14 +8,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxNotifications = 30
// ByUser shows all notifications sent to the given user.
func ByUser(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusBadRequest, "Not logged in")

View File

@ -6,14 +6,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils"
paypalsdk "github.com/logpacker/PayPal-Go-SDK"
)
// CreatePayment creates the PayPal payment, typically via a JSON API route.
func CreatePayment(ctx aero.Context) error {
// Make sure the user is logged in
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -10,7 +10,6 @@ import (
"github.com/animenotifier/notify.moe/arn/stringutils"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const adminID = "4J6qpK1ve"
@ -18,7 +17,7 @@ const adminID = "4J6qpK1ve"
// Success is called once the payment has been confirmed by the user on the PayPal website.
// However, the actual payment still needs to be executed and can fail.
func Success(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -6,14 +6,13 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
// Get post edit page.
func Get(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this post")

View File

@ -7,13 +7,12 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Get post.
func Get(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
post, err := arn.GetPost(id)
if err != nil {

View File

@ -6,13 +6,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// ReplyUI renders a new post area.
func ReplyUI(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
post, err := arn.GetPost(id)
if err != nil {

View File

@ -21,6 +21,6 @@ package profile
// followers := viewUser.Followers()
// arn.SortUsersLastSeenFirst(followers)
// return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.Path()))
// return ctx.HTML(components.ProfileFollowers(followers, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
// }

View File

@ -27,6 +27,6 @@ package profile
// posts = posts[:postLimit]
// }
// return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.Path()))
// return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
// }

View File

@ -33,7 +33,7 @@ func Get(ctx aero.Context) error {
// Profile renders the user profile page of the given viewUser.
func Profile(ctx aero.Context, viewUser *arn.User) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
sortBy := arn.SortByRating
if user != nil {

View File

@ -7,7 +7,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Liked shows all liked characters of a particular user.
@ -40,5 +39,5 @@ func Liked(ctx aero.Context) error {
// return aLikes > bLikes
})
return ctx.HTML(components.ProfileCharacters(characters, viewUser, utils.GetUser(ctx), ctx.Path()))
return ctx.HTML(components.ProfileCharacters(characters, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
}

View File

@ -19,7 +19,7 @@ package profilequotes
// func render(ctx aero.Context, fetch func(userID string) []*arn.Quote) string {
// nick := ctx.Get("nick")
// index, _ := ctx.GetInt("index")
// user := utils.GetUser(ctx)
// user := arn.GetUserFromContext(ctx)
// viewUser, err := arn.GetUserByNick(nick)
// if err != nil {

View File

@ -19,7 +19,7 @@ package profiletracks
// func render(ctx aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
// nick := ctx.Get("nick")
// index, _ := ctx.GetInt("index")
// user := utils.GetUser(ctx)
// user := arn.GetUserFromContext(ctx)
// viewUser, err := arn.GetUserByNick(nick)
// if err != nil {

View File

@ -98,5 +98,5 @@ package profile
// arn.NewPieChart("Soundtracks", trackTags),
// }
// return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.Path()))
// return ctx.HTML(components.ProfileStats(&userStats, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
// }

View File

@ -27,5 +27,5 @@ package profile
// threads = threads[:maxThreads]
// }
// return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx), ctx.Path()))
// return ctx.HTML(components.ProfileThreads(threads, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
// }

View File

@ -9,13 +9,12 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
// Edit quote.
func Edit(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
quote, err := arn.GetQuote(id)

View File

@ -8,12 +8,11 @@ import (
"github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Get quote.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
id := ctx.Get("id")
quote, err := arn.GetQuote(id)

View File

@ -4,13 +4,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
// Best renders the best quotes.
func Best(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
// Fetch all eligible quotes

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/infinitescroll"
)
@ -12,7 +11,7 @@ const maxQuotes = 15
// Latest renders the latest quotes.
func Latest(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
index, _ := ctx.GetInt("index")
// Fetch all eligible quotes

View File

@ -7,7 +7,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const (
@ -18,7 +17,7 @@ const (
// Anime shows a list of recommended anime.
func Anime(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)

View File

@ -3,9 +3,8 @@ package search
import (
"net/http"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/arn/search"
"github.com/animenotifier/notify.moe/components"
)
@ -24,7 +23,7 @@ const (
// Get search page.
func Get(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -47,13 +46,13 @@ func Get(ctx aero.Context) error {
// GetEmptySearch renders the search page with no contents.
func GetEmptySearch(ctx aero.Context) error {
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, nil, utils.GetUser(ctx)))
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, nil, arn.GetUserFromContext(ctx)))
}
// Anime search.
func Anime(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -66,7 +65,7 @@ func Anime(ctx aero.Context) error {
// Characters search.
func Characters(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -79,7 +78,7 @@ func Characters(ctx aero.Context) error {
// Posts search.
func Posts(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -92,7 +91,7 @@ func Posts(ctx aero.Context) error {
// Threads search.
func Threads(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -105,7 +104,7 @@ func Threads(ctx aero.Context) error {
// SoundTracks search.
func SoundTracks(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
@ -118,7 +117,7 @@ func SoundTracks(ctx aero.Context) error {
// AMVs search.
func AMVs(ctx aero.Context) error {
term := ctx.Get("term")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)

View File

@ -5,13 +5,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
)
// Get settings.
func Get(component func(*arn.User) string) func(aero.Context) error {
return func(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -6,7 +6,6 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
)
var itemBuyMutex sync.Mutex
@ -18,7 +17,7 @@ func BuyItem(ctx aero.Context) error {
defer itemBuyMutex.Unlock()
// Logged in user
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -7,12 +7,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// PurchaseHistory ...
func PurchaseHistory(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -8,12 +8,11 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get shop page.
func Get(ctx aero.Context) error {
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in")

View File

@ -5,13 +5,12 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/utils"
)
// Download tries to refresh the soundtrack file.
func Download(ctx aero.Context) error {
id := ctx.Get("id")
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this soundtrack")

View File

@ -5,7 +5,6 @@ import (
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
"github.com/aerogo/aero"
@ -16,7 +15,7 @@ import (
func Edit(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)

View File

@ -14,7 +14,7 @@ import (
func Lyrics(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)

View File

@ -7,14 +7,13 @@ import (
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/middleware"
"github.com/animenotifier/notify.moe/utils"
)
// Get track.
func Get(ctx aero.Context) error {
id := ctx.Get("id")
track, err := arn.GetSoundTrack(id)
user := utils.GetUser(ctx)
user := arn.GetUserFromContext(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)

Some files were not shown because too many files have changed in this diff Show More