This commit is contained in:
Alicia 2019-02-24 14:56:23 +00:00
parent 95754bffef
commit 3f08657c4d

View File

@ -2,10 +2,10 @@ package v1
import ( import (
"database/sql" "database/sql"
"github.com/osuYozora/api/common"
"sort"
"fmt" "fmt"
"sort"
"strconv" "strconv"
"github.com/osuYozora/common"
) )
type singleClan struct { type singleClan struct {
@ -53,11 +53,11 @@ func ClansGET(md common.MethodData) common.CodeMessager {
return r return r
} }
type clanMembersData struct { type clanMembersData struct {
common.ResponseBase common.ResponseBase
Members []userNotFullResponseLmao `json:"members"` Members []userNotFullResponseLmao `json:"members"`
} }
// get total stats of clan. later. // get total stats of clan. later.
type totalStats struct { type totalStats struct {
common.ResponseBase common.ResponseBase
@ -115,7 +115,6 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
fmt.Println(brr) fmt.Println(brr)
m = 0 m = 0
} }
n := "std" n := "std"
if m == 1 { if m == 1 {
n = "taiko" n = "taiko"
@ -198,9 +197,6 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
return r return r
} }
func TotalClanStatsGET(md common.MethodData) common.CodeMessager { func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
var ( var (
r megaStats r megaStats
@ -235,7 +231,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
//RETARD CODE HAHAAAA //RETARD CODE HAHAAAA
m, brr := strconv.ParseInt(string(md.Query("m")[11]), 10, 64) m, brr := strconv.ParseInt(string(md.Query("m")[11]), 10, 64)
if brr != nil { if brr != nil {
fmt.Printf("%v", brr) fmt.Println(brr)
} }
n := "std" n := "std"
@ -248,6 +244,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
} else { } else {
n = "std" n = "std"
} }
fmt.Println(n)
for i := 0; i < len(r.Clans); i++ { for i := 0; i < len(r.Clans); i++ {
var members clanMembersData var members clanMembersData
@ -271,7 +268,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
`, rid) `, rid)
if err != nil { if err != nil {
fmt.Printf("%v", brr) fmt.Println(err)
} }
members.Code = 200 members.Code = 200
@ -387,15 +384,23 @@ type imRetarded struct {
common.ResponseBase common.ResponseBase
Invite string `json:"invite"` Invite string `json:"invite"`
} }
type adminClan struct {
Id int `json:"user"`
Perms int `json:"perms"`
}
func ClanInviteGET(md common.MethodData) common.CodeMessager { func ClanInviteGET(md common.MethodData) common.CodeMessager {
// big perms check lol ok // big perms check lol ok
n := common.Int(md.Query("id")) n := common.Int(md.Query("id"))
adminRetard := adminClan{}
var r imRetarded var r imRetarded
var clan int var clan int
// get user clan, then get invite // get user clan, then get invite
md.DB.QueryRow("SELECT clan FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&clan) md.DB.QueryRow("SELECT user, clan, perms FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&adminRetard.Id, &clan, &adminRetard.Perms)
if adminRetard.Perms < 8 || adminRetard.Id != md.ID() {
return common.SimpleResponse(500, "You are not admin of there clan")
}
row := md.DB.QueryRow("SELECT invite FROM clans_invites WHERE clan = ? LIMIT 1", clan).Scan(&r.Invite) row := md.DB.QueryRow("SELECT invite FROM clans_invites WHERE clan = ? LIMIT 1", clan).Scan(&r.Invite)
if row != nil { if row != nil {
fmt.Println(row) fmt.Println(row)