forked from AkkomaGang/admin-fe
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') {
|
||||
accum[item.tuple[0]] = item.tuple[1] === ':disabled' ? [item.tuple[1]] : item.tuple[1].tuple
|
||||
} else if (item.tuple[0] === ':proxy_url') {
|
||||
accum[item.tuple[0]] = parseProxyUrl(item.tuple[1])
|
||||
} else if (item.tuple[0] === ':proxy_url' || item.tuple[0] === ':sender') {
|
||||
accum[item.tuple[0]] = parseStringOrTupleValue(item.tuple[0], item.tuple[1])
|
||||
} else if (item.tuple[0] === ':args') {
|
||||
accum[item.tuple[0]] = parseNonTuples(item.tuple[0], item.tuple[1])
|
||||
} else if (Array.isArray(item.tuple[1]) &&
|
||||
|
@ -122,7 +122,8 @@ const parseObject = object => {
|
|||
}, {})
|
||||
}
|
||||
|
||||
const parseProxyUrl = value => {
|
||||
const parseStringOrTupleValue = (key, value) => {
|
||||
if (key === ':proxy_url') {
|
||||
if (value && !Array.isArray(value) &&
|
||||
typeof value === 'object' &&
|
||||
value.tuple.length === 3 &&
|
||||
|
@ -134,6 +135,16 @@ const parseProxyUrl = value => {
|
|||
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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const prependWithСolon = (type, value) => {
|
||||
|
|
|
@ -8,4 +8,5 @@ export { default as PruneInput } from './PruneInput'
|
|||
export { default as RateLimitInput } from './RateLimitInput'
|
||||
export { default as RegInvitesInput } from './RegInvitesInput'
|
||||
export { default as SelectInputWithReducedLabels } from './SelectInputWithReducedLabels'
|
||||
export { default as SenderInput } from './SenderInput'
|
||||
export { default as SpecificMultipleSelect } from './SpecificMultipleSelect'
|
||||
|
|
Loading…
Reference in a new issue