Add parsing Sender settings value
This commit is contained in:
parent
54c8c2ddeb
commit
3d1087986f
2 changed files with 25 additions and 13 deletions
|
@ -89,8 +89,8 @@ export const parseTuples = (tuples, key) => {
|
||||||
}, [])
|
}, [])
|
||||||
} else if (item.tuple[0] === ':prune') {
|
} else if (item.tuple[0] === ':prune') {
|
||||||
accum[item.tuple[0]] = item.tuple[1] === ':disabled' ? [item.tuple[1]] : item.tuple[1].tuple
|
accum[item.tuple[0]] = item.tuple[1] === ':disabled' ? [item.tuple[1]] : item.tuple[1].tuple
|
||||||
} else if (item.tuple[0] === ':proxy_url') {
|
} else if (item.tuple[0] === ':proxy_url' || item.tuple[0] === ':sender') {
|
||||||
accum[item.tuple[0]] = parseProxyUrl(item.tuple[1])
|
accum[item.tuple[0]] = parseStringOrTupleValue(item.tuple[0], item.tuple[1])
|
||||||
} else if (item.tuple[0] === ':args') {
|
} else if (item.tuple[0] === ':args') {
|
||||||
accum[item.tuple[0]] = parseNonTuples(item.tuple[0], item.tuple[1])
|
accum[item.tuple[0]] = parseNonTuples(item.tuple[0], item.tuple[1])
|
||||||
} else if (Array.isArray(item.tuple[1]) &&
|
} else if (Array.isArray(item.tuple[1]) &&
|
||||||
|
@ -122,18 +122,29 @@ const parseObject = object => {
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseProxyUrl = value => {
|
const parseStringOrTupleValue = (key, value) => {
|
||||||
if (value && !Array.isArray(value) &&
|
if (key === ':proxy_url') {
|
||||||
typeof value === 'object' &&
|
if (value && !Array.isArray(value) &&
|
||||||
value.tuple.length === 3 &&
|
typeof value === 'object' &&
|
||||||
value.tuple[0] === ':socks5') {
|
value.tuple.length === 3 &&
|
||||||
const [, host, port] = value.tuple
|
value.tuple[0] === ':socks5') {
|
||||||
return { socks5: true, host, port }
|
const [, host, port] = value.tuple
|
||||||
} else if (typeof value === 'string') {
|
return { socks5: true, host, port }
|
||||||
const [host, port] = value.split(':')
|
} else if (typeof value === 'string') {
|
||||||
return { socks5: false, host, port }
|
const [host, port] = value.split(':')
|
||||||
|
return { socks5: false, host, port }
|
||||||
|
}
|
||||||
|
return { socks5: false, host: null, port: null }
|
||||||
|
} else if (key === ':sender') {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
return { email: value }
|
||||||
|
} else if (value &&
|
||||||
|
typeof value === 'object' &&
|
||||||
|
value.tuple.length === 2) {
|
||||||
|
const [nickname, email] = value.tuple
|
||||||
|
return { nickname, email }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { socks5: false, host: null, port: null }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const prependWithСolon = (type, value) => {
|
const prependWithСolon = (type, value) => {
|
||||||
|
|
|
@ -8,4 +8,5 @@ export { default as PruneInput } from './PruneInput'
|
||||||
export { default as RateLimitInput } from './RateLimitInput'
|
export { default as RateLimitInput } from './RateLimitInput'
|
||||||
export { default as RegInvitesInput } from './RegInvitesInput'
|
export { default as RegInvitesInput } from './RegInvitesInput'
|
||||||
export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'
|
export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'
|
||||||
|
export { default as SenderInput } from './SenderInput'
|
||||||
export { default as SpecificMultipleSelect } from './SpecificMultipleSelect'
|
export { default as SpecificMultipleSelect } from './SpecificMultipleSelect'
|
||||||
|
|
Loading…
Reference in a new issue