Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.

Skip to content
Snippets Groups Projects
Commit e78f1905 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Imap4flags: now reads initial flags and keywords from supplied mail. Upon...

Imap4flags: now reads initial flags and keywords from supplied mail. Upon delivery this is empty, which still matches the specification.
parent a61fb923
No related branches found
No related tags found
No related merge requests found
......@@ -167,6 +167,38 @@ struct ext_imap4flags_result_context {
string_t *internal_flags;
};
static void _get_initial_flags
(struct sieve_result *result, string_t *flags)
{
const struct sieve_message_data *msgdata =
sieve_result_get_message_data(result);
enum mail_flags mail_flags;
const char *const *mail_keywords;
mail_flags = mail_get_flags(msgdata->mail);
mail_keywords = mail_get_keywords(msgdata->mail);
if ( (mail_flags & MAIL_FLAGGED) > 0 )
str_printfa(flags, " \\flagged");
if ( (mail_flags & MAIL_ANSWERED) > 0 )
str_printfa(flags, " \\answered");
if ( (mail_flags & MAIL_DELETED) > 0 )
str_printfa(flags, " \\deleted");
if ( (mail_flags & MAIL_SEEN) > 0 )
str_printfa(flags, " \\seen");
if ( (mail_flags & MAIL_DRAFT) > 0 )
str_printfa(flags, " \\draft");
while ( *mail_keywords != NULL ) {
str_printfa(flags, " %s", *mail_keywords);
mail_keywords++;
}
}
static inline struct ext_imap4flags_result_context *_get_result_context
(struct sieve_result *result)
{
......@@ -179,6 +211,7 @@ static inline struct ext_imap4flags_result_context *_get_result_context
rctx =p_new(pool, struct ext_imap4flags_result_context, 1);
rctx->internal_flags = str_new(pool, 32);
_get_initial_flags(result, rctx->internal_flags);
sieve_result_extension_set_context
(result, &imap4flags_extension, rctx);
......
......@@ -11,11 +11,26 @@ require "comparator-i;ascii-numeric";
test "Hasflag empty" {
if hasflag "\\Seen" {
test_fail "hasflag sees flags were there should be none";
test_fail "hasflag sees initial \\seen flag were there should be none";
}
if hasflag "\\draft" {
test_fail "hasflag sees initial \\draft flag were there should be none";
}
if hasflag "\\recent" {
test_fail "hasflag sees initial \\recent flag were there should be none";
}
if hasflag "\\flagged" {
test_fail "hasflag sees initial \\flagged flag were there should be none";
}
if hasflag "\\answered" {
test_fail "hasflag sees initial \\answered flag were there should be none";
}
if hasflag "\\deleted" {
test_fail "hasflag sees initial \\deleted flag were there should be none";
}
if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
test_fail "hasflag sees flags were there should be none";
test_fail "hasflag sees initial flags were there should be none";
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment