Add messages to all api calls
This commit is contained in:
parent
cc45794497
commit
dba1976a8e
|
@ -205,7 +205,7 @@ const start = async (): Promise<void> => {
|
|||
requestEvent.respondWith(stdResp.TooManyRequests('Slow down, servers are expensive and this bot is free to use.'));
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('Why are you here?'));
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -76,10 +76,10 @@ export const apiKeyDelete = async (requestEvent: Deno.RequestEvent, query: Map<s
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('You can only delete your own key.'));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -30,10 +30,10 @@ export const apiChannel = async (requestEvent: Deno.RequestEvent, query: Map<str
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('You can only view your own channels.'));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -44,11 +44,11 @@ export const apiKey = async (requestEvent: Deno.RequestEvent, query: Map<string,
|
|||
return;
|
||||
} else {
|
||||
// Send basic OK to indicate key has been sent
|
||||
requestEvent.respondWith(stdResp.OK(''));
|
||||
requestEvent.respondWith(stdResp.OK('Email Sent.'));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -35,10 +35,10 @@ export const apiKeyAdmin = async (requestEvent: Deno.RequestEvent, query: Map<st
|
|||
}
|
||||
} else {
|
||||
// Only allow the db admin to use this API
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden(stdResp.Strings.restricted));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -119,6 +119,6 @@ export const apiRoll = async (requestEvent: Deno.RequestEvent, query: Map<string
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,10 +29,10 @@ export const apiChannelAdd = async (requestEvent: Deno.RequestEvent, query: Map<
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('You can only add channels to your key.'));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -36,10 +36,10 @@ export const apiChannelManageActive = async (requestEvent: Deno.RequestEvent, qu
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('You can only manage your own channels.'));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -40,10 +40,10 @@ export const apiChannelManageBan = async (requestEvent: Deno.RequestEvent, query
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden(stdResp.Strings.restricted));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -46,10 +46,10 @@ export const apiKeyManage = async (requestEvent: Deno.RequestEvent, query: Map<s
|
|||
}
|
||||
} else {
|
||||
// Alert API user that they shouldn't be doing this
|
||||
requestEvent.respondWith(stdResp.Forbidden(''));
|
||||
requestEvent.respondWith(stdResp.Forbidden('You can only manage your own key.'));
|
||||
}
|
||||
} else {
|
||||
// Alert API user that they messed up
|
||||
requestEvent.respondWith(stdResp.BadRequest(''));
|
||||
requestEvent.respondWith(stdResp.BadRequest(stdResp.Strings.missingParams));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,4 +16,8 @@ export default {
|
|||
OK: (customText: string) => genericResponse(customText, Status.OK),
|
||||
RequestTimeout: (customText: string) => genericResponse(customText, Status.RequestTimeout),
|
||||
TooManyRequests: (customText: string) => genericResponse(customText, Status.TooManyRequests),
|
||||
Strings: {
|
||||
missingParams: 'Missing Parameters.',
|
||||
restricted: 'This API is restricted.',
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue