guard against some edge cases for allow/wait lists

This commit is contained in:
Joey Zhou 2023-08-16 17:00:49 -07:00
Родитель 024774fbea
Коммит e625e6bee3
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -42,8 +42,8 @@ async function addFeatureFlag(flag: FeatureFlag) {
is_enabled: flag.isEnabled,
description: flag.description,
dependencies: flag.dependencies,
allow_list: flag.allowList,
wait_list: flag.waitList,
allow_list: flag.allowList?.map((email) => email.trim()).filter((e) => !!e),
wait_list: flag.waitList?.map((email) => email.trim()).filter((e) => !!e),
expired_at: flag.expiredAt,
owner: flag.owner,
};
@ -96,6 +96,7 @@ async function updateOwner(name: string, owner: string) {
}
async function updateAllowList(name: string, allowList: string[]) {
allowList = allowList.map((email) => email.trim()).filter((e) => !!e);
log.info("updateAllowList", { name, allowList });
const res = await knex("feature_flags")
.where("name", name)
@ -111,6 +112,7 @@ async function updateAllowList(name: string, allowList: string[]) {
}
async function updateWaitList(name: string, waitList: string[]) {
waitList = waitList.map((email) => email.trim()).filter((e) => !!e);
log.info("updateWaitList", { name, waitList });
const res = await knex("feature_flags")
.where("name", name)