Skip to content

Commit bf8001d

Browse files
authored
feat: Check for unique label ids and names (#446)
1 parent fb72422 commit bf8001d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/writer/settings.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ export async function verify(body): Promise<any> {
9797

9898
if (!isController && !isEqual(admins, newAdmins))
9999
return Promise.reject('not allowed change admins');
100+
101+
const labels = msg.payload.labels || [];
102+
if (labels.length) {
103+
const uniqueLabelsIds = new Set<string>();
104+
const uniqueLabelsNames = new Set<string>();
105+
for (const { id, name } of labels) {
106+
const labelId = id.toLowerCase();
107+
const labelName = name.toLowerCase();
108+
if (uniqueLabelsIds.has(labelId)) {
109+
return Promise.reject('duplicate label id');
110+
}
111+
if (uniqueLabelsNames.has(labelName)) {
112+
return Promise.reject('duplicate label name');
113+
}
114+
uniqueLabelsIds.add(labelId);
115+
uniqueLabelsNames.add(labelName);
116+
}
117+
}
100118
}
101119

102120
export async function action(body): Promise<void> {

0 commit comments

Comments
 (0)