2016-10-29 13:42:39 +02:00
|
|
|
dbpath = /data/main.db
|
2016-02-20 21:11:59 +02:00
|
|
|
query =
|
2016-08-18 11:29:26 +02:00
|
|
|
SELECT destination
|
|
|
|
FROM
|
|
|
|
(SELECT destination, email, wildcard, localpart FROM alias
|
|
|
|
UNION
|
2017-09-10 15:30:25 +02:00
|
|
|
SELECT (CASE WHEN forward_enabled=1 THEN (CASE WHEN forward_keep=1 THEN email||',' ELSE '' END)||forward_destination ELSE email END) AS destination, email, 0 as wildcard, localpart FROM user
|
|
|
|
UNION
|
|
|
|
SELECT '@'||domain_name as destination, '@'||name as email, 0 as wildcard, '' as localpart FROM alternative)
|
2016-08-18 11:29:26 +02:00
|
|
|
WHERE
|
|
|
|
(
|
|
|
|
wildcard = 0
|
|
|
|
AND
|
|
|
|
email = '%s'
|
|
|
|
) OR (
|
|
|
|
wildcard = 1
|
|
|
|
AND
|
|
|
|
'%s' LIKE email
|
|
|
|
)
|
|
|
|
ORDER BY
|
|
|
|
wildcard ASC,
|
|
|
|
length(localpart) DESC
|
|
|
|
LIMIT 1
|