summaryrefslogtreecommitdiff
path: root/src/message/builder/cc.cpp
blob: b1861670010133746ee9e7b6f9b22afbc2f67d6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "cc.hpp"

namespace smtp::message::builder
{
    Cc::Cc( general::MailsSet const& mail_to )
        : mMailTo( mail_to )
    {

    }

    std::string Cc::Get() const
    {
        std::string result;
        if( mBase )
        {
            result = mBase->Get();
        }

        if( mMailTo.empty() )
        {
            return result;
        }

        for( const auto& cc : mMailTo )
        {
            if( !IsFirstElement( cc ) )
            {
                result += "Cc: " + cc + "\r\n";
            }
        }

        return result;
    }

    bool Cc::IsFirstElement( std::string const& cc ) const
    {
        return cc == *mMailTo.begin();
    }
}