mailto: add account query parameter
Specify an account parameter in the mailto argument. If not specified, the selected account is used as default. Example: $ aerc 'mailto:user@host?account=Fastmail' Suggested-by: staceee Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
aaf0a0c656
commit
903d436ab8
2 changed files with 16 additions and 5 deletions
|
@ -35,6 +35,8 @@ from your terminal.
|
||||||
: BCC header will be completed with the list of addresses
|
: BCC header will be completed with the list of addresses
|
||||||
| in-reply-to=<\<message-id\>>
|
| in-reply-to=<\<message-id\>>
|
||||||
: In-reply-to header will be set to the message id
|
: In-reply-to header will be set to the message id
|
||||||
|
| account=<accountname>
|
||||||
|
: Specify the account (must be in accounts.conf; default is the selected account)
|
||||||
|
|
||||||
Note that reserved characters in the queries must be percent encoded.
|
Note that reserved characters in the queries must be percent encoded.
|
||||||
|
|
||||||
|
|
|
@ -532,13 +532,9 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aerc *Aerc) Mailto(addr *url.URL) error {
|
func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
acct := aerc.SelectedAccount()
|
|
||||||
if acct == nil {
|
|
||||||
return errors.New("No account selected")
|
|
||||||
}
|
|
||||||
|
|
||||||
var subject string
|
var subject string
|
||||||
var body string
|
var body string
|
||||||
|
var acctName string
|
||||||
h := &mail.Header{}
|
h := &mail.Header{}
|
||||||
to, err := mail.ParseAddressList(addr.Opaque)
|
to, err := mail.ParseAddressList(addr.Opaque)
|
||||||
if err != nil && addr.Opaque != "" {
|
if err != nil && addr.Opaque != "" {
|
||||||
|
@ -547,6 +543,8 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
h.SetAddressList("to", to)
|
h.SetAddressList("to", to)
|
||||||
for key, vals := range addr.Query() {
|
for key, vals := range addr.Query() {
|
||||||
switch strings.ToLower(key) {
|
switch strings.ToLower(key) {
|
||||||
|
case "account":
|
||||||
|
acctName = strings.Join(vals, "")
|
||||||
case "bcc":
|
case "bcc":
|
||||||
list, err := mail.ParseAddressList(strings.Join(vals, ","))
|
list, err := mail.ParseAddressList(strings.Join(vals, ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -578,6 +576,17 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acct := aerc.SelectedAccount()
|
||||||
|
if acctName != "" {
|
||||||
|
if a, ok := aerc.accounts[acctName]; ok && a != nil {
|
||||||
|
acct = a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if acct == nil {
|
||||||
|
return errors.New("No account selected")
|
||||||
|
}
|
||||||
|
|
||||||
composer, err := NewComposer(aerc, acct, aerc.Config(),
|
composer, err := NewComposer(aerc, acct, aerc.Config(),
|
||||||
acct.AccountConfig(), acct.Worker(), "", h, models.OriginalMail{})
|
acct.AccountConfig(), acct.Worker(), "", h, models.OriginalMail{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue