mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
notmuch reply: Don't reply to address belonging to the user.
Here's our first real advantage of having a configuration system. We get to omit our own addresses from the recipient list of any replies.
This commit is contained in:
parent
13569ad6c9
commit
dbe41eab82
1 changed files with 29 additions and 4 deletions
|
@ -71,8 +71,30 @@ reply_part(GMimeObject *part, int *part_count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Is the given address configured as one of the user's "personal" or
|
||||||
|
* "other" addresses. */
|
||||||
|
static int
|
||||||
|
address_is_users (const char *address, notmuch_config_t *config)
|
||||||
|
{
|
||||||
|
const char *primary;
|
||||||
|
char **other;
|
||||||
|
unsigned int i, other_len;
|
||||||
|
|
||||||
|
primary = notmuch_config_get_user_primary_email (config);
|
||||||
|
if (strcmp (primary, address) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
other = notmuch_config_get_user_other_email (config, &other_len);
|
||||||
|
for (i = 0; i < other_len; i++)
|
||||||
|
if (strcmp (other[i], address) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_recipients_for_address_list (GMimeMessage *message,
|
add_recipients_for_address_list (GMimeMessage *message,
|
||||||
|
notmuch_config_t *config,
|
||||||
GMimeRecipientType type,
|
GMimeRecipientType type,
|
||||||
InternetAddressList *list)
|
InternetAddressList *list)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +112,8 @@ add_recipients_for_address_list (GMimeMessage *message,
|
||||||
if (group_list == NULL)
|
if (group_list == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
add_recipients_for_address_list (message, type, group_list);
|
add_recipients_for_address_list (message, config,
|
||||||
|
type, group_list);
|
||||||
} else {
|
} else {
|
||||||
InternetAddressMailbox *mailbox;
|
InternetAddressMailbox *mailbox;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -101,6 +124,7 @@ add_recipients_for_address_list (GMimeMessage *message,
|
||||||
name = internet_address_get_name (address);
|
name = internet_address_get_name (address);
|
||||||
addr = internet_address_mailbox_get_addr (mailbox);
|
addr = internet_address_mailbox_get_addr (mailbox);
|
||||||
|
|
||||||
|
if (! address_is_users (addr, config))
|
||||||
g_mime_message_add_recipient (message, type, name, addr);
|
g_mime_message_add_recipient (message, type, name, addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +132,7 @@ add_recipients_for_address_list (GMimeMessage *message,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_recipients_for_string (GMimeMessage *message,
|
add_recipients_for_string (GMimeMessage *message,
|
||||||
|
notmuch_config_t *config,
|
||||||
GMimeRecipientType type,
|
GMimeRecipientType type,
|
||||||
const char *recipients)
|
const char *recipients)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +142,7 @@ add_recipients_for_string (GMimeMessage *message,
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
add_recipients_for_address_list (message, type, list);
|
add_recipients_for_address_list (message, config, type, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -194,7 +219,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
|
||||||
for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
|
for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
|
||||||
recipients = notmuch_message_get_header (message,
|
recipients = notmuch_message_get_header (message,
|
||||||
reply_to_map[i].header);
|
reply_to_map[i].header);
|
||||||
add_recipients_for_string (reply,
|
add_recipients_for_string (reply, config,
|
||||||
reply_to_map[i].recipient_type,
|
reply_to_map[i].recipient_type,
|
||||||
recipients);
|
recipients);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue