forked from PluralFlux/PluralFlux
reversed check for valid proxy (was returning valid if the proxy existed and invalid if it didn't)
This commit is contained in:
@@ -356,7 +356,8 @@ mh.addFullMember = async function (authorId, memberName, displayName = null, pro
|
||||
let isValidProxy;
|
||||
if (proxy && proxy.length > 0) {
|
||||
try {
|
||||
isValidProxy = await mh.checkIfProxyExists(authorId, proxy);
|
||||
const proxyExists = await mh.checkIfProxyExists(authorId, proxy);
|
||||
isValidProxy = !proxyExists;
|
||||
}
|
||||
catch(e) {
|
||||
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) {
|
||||
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]) => ({
|
||||
name: member.name, value: `(Proxy: \`${member.proxy ?? "unset"}\`)`, inline: true,
|
||||
}));
|
||||
|
||||
@@ -527,7 +527,7 @@ describe('MemberHelper', () => {
|
||||
|
||||
test('if proxy, call checkIfProxyExists', async () => {
|
||||
// Arrange
|
||||
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue();
|
||||
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(true);
|
||||
const expectedMemberArgs = {
|
||||
name: mockMember.name,
|
||||
userid: authorId,
|
||||
@@ -622,7 +622,7 @@ describe('MemberHelper', () => {
|
||||
|
||||
test('if all values are valid, call database.members.create', async () => {
|
||||
// Arrange
|
||||
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(true);
|
||||
jest.spyOn(memberHelper, 'checkIfProxyExists').mockResolvedValue(false);
|
||||
const expectedMemberArgs = {
|
||||
name: mockMember.name,
|
||||
userid: authorId,
|
||||
|
||||
Reference in New Issue
Block a user