From 0c79deb2adab0343f3968132024ba000284782e4 Mon Sep 17 00:00:00 2001 From: Dot-Rar Date: Fri, 17 Apr 2020 13:48:59 +0100 Subject: [PATCH] fix owner id --- app/http/endpoints/root/callback.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/http/endpoints/root/callback.go b/app/http/endpoints/root/callback.go index fde3372..ba03ea9 100644 --- a/app/http/endpoints/root/callback.go +++ b/app/http/endpoints/root/callback.go @@ -84,13 +84,22 @@ func CallbackHandler(ctx *gin.Context) { // Cache guilds because Discord takes like 2 whole seconds to return then go func() { - var guilds []guild.Guild + var guilds []*guild.Guild err, _ = userEndpoint.CurrentUserGuilds.Request(store, nil, nil, &guilds) if err != nil { log.Error(err.Error()) return } + // endpoint's partial guild doesn't include ownerid + // we only user cached guilds on the index page, so it doesn't matter if we don't have have the real owner id + // if the user isn't the owner, as we pull from the cache on other endpoints + for _, guild := range guilds { + if guild.Owner { + guild.OwnerId = currentUser.Id + } + } + marshalled, err := json.Marshal(guilds) if err != nil { log.Error(err.Error())