Add check for if you've denied the plugin permission to access api.github.com

This commit is contained in:
Micah 2026-07-05 22:31:22 -07:00
parent 7ade19293c
commit 5085688589
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

View file

@ -8,6 +8,7 @@ local Log = require(Packages.Log)
local Assets = require(Plugin.Assets) local Assets = require(Plugin.Assets)
local Settings = require(Plugin.Settings) local Settings = require(Plugin.Settings)
local Theme = require(Plugin.App.Theme) local Theme = require(Plugin.App.Theme)
local Version = require(Plugin.Version)
local IconButton = require(Plugin.App.Components.IconButton) local IconButton = require(Plugin.App.Components.IconButton)
local ScrollingFrame = require(Plugin.App.Components.ScrollingFrame) local ScrollingFrame = require(Plugin.App.Components.ScrollingFrame)
@ -193,6 +194,8 @@ function SettingsPage:render()
id = "checkForUpdates", id = "checkForUpdates",
name = "Check For Updates", name = "Check For Updates",
description = "Notify about newer compatible Rojo releases", description = "Notify about newer compatible Rojo releases",
locked = Version.isApiBlocked(),
lockedTooltip = "(HTTP requests to api.github.com are blocked, Rojo cannot fetch what the latest version is.)",
transparency = self.props.transparency, transparency = self.props.transparency,
layoutOrder = layoutIncrement(), layoutOrder = layoutIncrement(),
}), }),

View file

@ -111,6 +111,23 @@ Version._cachedLatestCompatible = nil :: {
timestamp: number, timestamp: number,
}? }?
--[[
A user may choose to reject requests to api.github.com. If they do, we want
to disable the option to enable checks altogether.
]]
Version._apiBlocked = nil :: boolean?
function Version.isApiBlocked(): boolean
if Version._apiBlocked == nil then
local isLocalInstall = string.find(debug.traceback(), "\n[^\n]-user_.-$") ~= nil
Version.retrieveLatestCompatible({
version = Config.version,
includePrereleases = isLocalInstall and Settings:get("checkForPrereleases"),
})
end
return Version._apiBlocked
end
function Version.retrieveLatestCompatible(options: { function Version.retrieveLatestCompatible(options: {
version: { number }, version: { number },
includePrereleases: boolean?, includePrereleases: boolean?,
@ -136,8 +153,15 @@ function Version.retrieveLatestCompatible(options: {
:await() :await()
if success == false or type(releases) ~= "table" or next(releases) ~= 1 then if success == false or type(releases) ~= "table" or next(releases) ~= 1 then
-- Roblox's HTTP errors are weird!
if string.find(tostring(releases), "^Unknown HTTP error: HttpService permission denied") then
Log.debug("Requests to api.github were denied by user, disabling update check")
Settings:set("checkForUpdates", false)
Version._apiBlocked = true
end
return nil return nil
end end
Version._apiBlocked = false
-- Iterate through releases, looking for the latest compatible version -- Iterate through releases, looking for the latest compatible version
local latestCompatible: LatestReleaseInfo? = nil local latestCompatible: LatestReleaseInfo? = nil