aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apactor.cpp
blob: 78ed9a3fbbbbe8f10a7700ee252dc0e6d0c6c4f3 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "apactor.h"
#include <QDebug>

APActor::APActor() {}

APActor::APActor(const QString& url) {
    object_url = url;
}

APActor::APActor(APActorFields& fields) {
    object_url = fields.url;
    username = fields.username;
    name = fields.display_name;
    summary = fields.summary;
    manuallyApprovesFollowers = fields.manuallyApprovesFollowers;
    discoverable = fields.discoverable;
    joined = QDateTime::fromString(fields.joined_date, Qt::ISODate);
    avatar = fields.avatar;
    header = fields.header;

    if (fields.keys.length() == fields.values.length())
        for (int i = 0; i < fields.keys.length(); ++i)
            table.push_back({fields.keys[i], fields.values[i]});
    else qDebug() << "key and value vectors don't have the same lenght!";
}

APActor::~APActor() {
    if (avatar) delete avatar;
    if (header) delete header;
}

const QString APActor::get_url() {
    return object_url;
}

QString APActor::get_html_render(HtmlRenderDetails render_info) {
    // TODO: could be made nicer with profile images
    return object_url;
}

const QString APActor::get_plain_render() {
    return object_url;
}

QString APActorList::get_html_render(HtmlRenderDetails render_info) {
    // have something basic for the moment
    QString text;

    for (APActor elem : *this)
        text.append(elem.get_plain_render() + ", ");

    if (text.isEmpty())
        text = "<em>(empty)</em>";
    else
        text.chop(2); // remove leftover ", "

    return text;
}