Skip to content

Commit

Permalink
patch to show only write guilds in Imports (#1642)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashish Jhanwar <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Apr 19, 2024
1 parent bd68a11 commit ac517d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion customcommands/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ func PublicCommandMW(inner http.Handler) http.Handler {
templateData["PublicAccess"] = true

if _, ok := ctx.Value(common.ContextKeyUser).(*discordgo.User); ok {
guilds, _ := web.GetUserManagedGuilds(r.Context())
guilds, _ := web.GetUserAccessibleGuilds(r.Context(), true)
templateData["UserGuilds"] = guilds
}
// retrieve the cc's page
Expand Down
6 changes: 3 additions & 3 deletions web/handlers_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func HandleGetManagedGuilds(w http.ResponseWriter, r *http.Request) (TemplateDat
ctx := r.Context()
_, templateData := GetBaseCPContextData(ctx)

managedGuilds, err := GetUserManagedGuilds(ctx)
managedGuilds, err := GetUserAccessibleGuilds(ctx, false)
if err != nil {
return templateData, err
}
Expand All @@ -520,7 +520,7 @@ func basicRoleProvider(guildID, userID int64) []int64 {
return members[0].Roles
}

func GetUserManagedGuilds(ctx context.Context) ([]*common.GuildWithConnected, error) {
func GetUserAccessibleGuilds(ctx context.Context, writeOnly bool) ([]*common.GuildWithConnected, error) {
guilds, err := GetUserGuilds(ctx)
if err != nil {
return nil, err
Expand All @@ -534,7 +534,7 @@ func GetUserManagedGuilds(ctx context.Context) ([]*common.GuildWithConnected, er
for i, g := range guilds {
go func(j int, gwc *common.GuildWithConnected) {
conf := common.GetCoreServerConfCached(gwc.ID)
if HasAccesstoGuildSettings(user.ID, gwc, conf, basicRoleProvider, false) {
if HasAccesstoGuildSettings(user.ID, gwc, conf, basicRoleProvider, writeOnly) {
nilled[j] = gwc
}
wg.Done()
Expand Down

0 comments on commit ac517d1

Please sign in to comment.