reversed check for valid proxy (was returning valid if the proxy existed and invalid if it didn't)

This commit is contained in:
Aster Fialla
2026-02-24 20:29:23 -05:00
parent 545136bec7
commit dad80bd385
2 changed files with 5 additions and 4 deletions

View File

@@ -356,7 +356,8 @@ mh.addFullMember = async function (authorId, memberName, displayName = null, pro
let isValidProxy; let isValidProxy;
if (proxy && proxy.length > 0) { if (proxy && proxy.length > 0) {
try { try {
isValidProxy = await mh.checkIfProxyExists(authorId, proxy); const proxyExists = await mh.checkIfProxyExists(authorId, proxy);
isValidProxy = !proxyExists;
} }
catch(e) { catch(e) {
errors.push(`Tried to set proxy to \"${proxy}\". ${e.message}. ${enums.err.SET_TO_NULL}`); errors.push(`Tried to set proxy to \"${proxy}\". ${e.message}. ${enums.err.SET_TO_NULL}`);
@@ -460,7 +461,7 @@ mh.getMemberInfo = function (member) {
*/ */
mh.getAllMembersInfo = async function (authorId, authorName) { mh.getAllMembersInfo = async function (authorId, authorName) {
const members = await mh.getMembersByAuthor(authorId); const members = await mh.getMembersByAuthor(authorId);
if (members == null) throw Error(enums.err.USER_NO_MEMBERS); if (members.length === 0) throw Error(enums.err.USER_NO_MEMBERS);
const fields = [...members.entries()].map(([name, member]) => ({ const fields = [...members.entries()].map(([name, member]) => ({
name: member.name, value: `(Proxy: \`${member.proxy ?? "unset"}\`)`, inline: true, name: member.name, value: `(Proxy: \`${member.proxy ?? "unset"}\`)`, inline: true,
})); }));

View File

@@ -527,7 +527,7 @@ describe('MemberHelper', () => {
test('if proxy, call checkIfProxyExists', async () => { test('if proxy, call checkIfProxyExists', async () => {
// Arrange // Arrange
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(); jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(true);
const expectedMemberArgs = { const expectedMemberArgs = {
name: mockMember.name, name: mockMember.name,
userid: authorId, userid: authorId,
@@ -622,7 +622,7 @@ describe('MemberHelper', () => {
test('if all values are valid, call database.members.create', async () => { test('if all values are valid, call database.members.create', async () => {
// Arrange // Arrange
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(true); jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(false);
const expectedMemberArgs = { const expectedMemberArgs = {
name: mockMember.name, name: mockMember.name,
userid: authorId, userid: authorId,