Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/profile/book.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ const Book: FC<Props> = ({ userBook, onRefetch, logbookPermissions, isSelf }) =>
const response = await axios.get(
`/api/workspace/${id}/external/ranking`
);
setRankingEnabled(
response.data.rankGunEnabled ? response.data.rankGunEnabled : response.data.openCloudEnabled ? response.data.rankGunEnabled : false
const enabled = Boolean(
response.data.rankingEnabled ??
(response.data.rankGunEnabled || response.data.openCloudEnabled)
);
return response.data.rankGunEnabled ? response.data.rankGunEnabled : response.data.openCloudEnabled ? response.data.rankGunEnabled : false;
setRankingEnabled(enabled);
return enabled;
} catch (error) {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions components/settings/instance/external.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ const ExternalServicesImpl: FC<ExternalServicesProps> = ({
</option>
))}
</select>
{!rankingProvider && (
<p className="mt-1.5 text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500">
Promotion, demotion, and termination logs will not change ranks in
the Roblox group.
</p>
)}
</div>

{rankingProvider === "rankgun" && (
Expand Down
14 changes: 11 additions & 3 deletions pages/api/workspace/[id]/external/ranking.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { withPermissionCheck } from "@/utils/permissionsManager";
import { getRankGun } from "@/utils/rankgun";
import { getConfig } from "@/utils/configEngine";
import prisma from "@/utils/database";

export default withPermissionCheck(handler, "rank_users");

Expand All @@ -22,11 +22,19 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const workspaceGroupId = parseInt(id as string);
const rankGun = await getRankGun(workspaceGroupId);
const openCloudConfig = await getConfig("roblox_opencloud", workspaceGroupId)
const external = await prisma.workspaceExternalServices.findFirst({
where: { workspaceGroupId },
});
const openCloudEnabled =
external?.rankingProvider === "opencloudranking" &&
typeof external.rankingToken === "string" &&
external.rankingToken.length > 0;
const rankingEnabled = !!rankGun || openCloudEnabled;
return res.status(200).json({
success: true,
rankGunEnabled: !!rankGun,
openCloudEnabled: !!openCloudConfig.enabled
openCloudEnabled,
rankingEnabled,
});
} catch (error) {
return res.status(500).json({
Expand Down
6 changes: 5 additions & 1 deletion pages/api/workspace/[id]/settings/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
updatedAt: new Date(),
};

if (clearRankingToken) {
if (!rankingProvider) {
updatePayload.rankingToken = null;
updatePayload.rankingWorkspaceId = null;
updatePayload.rankingMaxRank = null;
} else if (clearRankingToken) {
updatePayload.rankingToken = null;
} else if (tokenTrim !== "") {
updatePayload.rankingToken = tokenTrim;
Expand Down
Loading
Loading