Skip to content

Commit

Permalink
Merge pull request #29 from osuAkatsuki/allow-for-fa-custom-badges
Browse files Browse the repository at this point in the history
Allow for fa custom badges
  • Loading branch information
lenforiee authored Sep 18, 2023
2 parents 68207ce + 8e5b804 commit 4674ca4
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions app/v1/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"strings"

"github.com/osuAkatsuki/akatsuki-api/common"
"zxq.co/ripple/semantic-icons-ugc"
)

type donorInfoResponse struct {
Expand Down Expand Up @@ -74,7 +73,7 @@ func UsersSelfSettingsPOST(md common.MethodData) common.CodeMessager {
// input sanitisation
if md.User.UserPrivileges&common.UserPrivilegeDonor > 0 {
d.CustomBadge.Name = common.SanitiseString(d.CustomBadge.Name)
d.CustomBadge.Icon = sanitiseIconName(d.CustomBadge.Icon)
// d.CustomBadge.Icon = sanitiseIconName(d.CustomBadge.Icon)
} else {
d.CustomBadge.singleBadge = singleBadge{}
d.CustomBadge.Show = nil
Expand All @@ -96,26 +95,6 @@ func UsersSelfSettingsPOST(md common.MethodData) common.CodeMessager {
return UsersSelfSettingsGET(md)
}

func sanitiseIconName(s string) string {
classes := strings.Split(s, " ")
n := make([]string, 0, len(classes))
for _, c := range classes {
if !in(c, n) && in(c, semanticiconsugc.SaneIcons) {
n = append(n, c)
}
}
return strings.Join(n, " ")
}

func in(a string, b []string) bool {
for _, x := range b {
if x == a {
return true
}
}
return false
}

type userSettingsResponse struct {
common.ResponseBase
ID int `json:"id"`
Expand Down

0 comments on commit 4674ca4

Please sign in to comment.