mx: adds automatic priority for mx record lists + publishing

This commit is contained in:
Akshay Nair
2021-09-02 15:24:17 +05:30
parent 8d4788c61b
commit eb484fe163
5 changed files with 36 additions and 25 deletions
+5 -4
View File
@@ -10,18 +10,19 @@ const toHostList = R.chain(data => {
const rs = getRecords(data.record);
return R.chain(([recordType, urls]) =>
(Array.isArray(urls) ? urls : [urls]).map(url => ({
(Array.isArray(urls) ? urls : [urls]).map((url, index) => ({
name: data.name,
type: recordType,
address: (recordType === 'CNAME' ? `${url}`.toLowerCase() : `${url}`).replace(/\/$/g, ''),
ttl: TTL,
...(recordType === 'MX' ? { priority: index + 20 } : {})
}))
, rs);
, rs);
});
const registerDomains = async ({ domainService, getDomains, log = () => {} }) => {
const registerDomains = async ({ domainService, getDomains, log = () => { } }) => {
const domains = await getDomains().then(toHostList);
if (domains.length === 0)
return Promise.reject(new Error('Nothing to register'));