From 5ed7d9b53a65aec1f4793f62ac15195c44224b39 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Tue, 18 Jul 2023 00:00:20 +0200 Subject: Implement Question object type support This commit adds support for dealing with ActivityPub Questions, which are polls. They are like Notes (posts) but contain a few more keys that record information about the poll options, number of votes and poll closure date. --- src/activitypub/apquestion.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/activitypub/apquestion.h (limited to 'src/activitypub/apquestion.h') diff --git a/src/activitypub/apquestion.h b/src/activitypub/apquestion.h new file mode 100644 index 0000000..350ceec --- /dev/null +++ b/src/activitypub/apquestion.h @@ -0,0 +1,34 @@ +#pragma once + +#include "appost.h" +#include "apbase.h" +#include "fields.h" +#include +#include + +// APQuestion represents an ActivityPub Question Object +class APQuestion : public APPost { +public: + APQuestion(); + // A post that will be built from strings, including attachments + APQuestion(APObjectFields fields); + ~APQuestion() {}; + + QString get_html_render(HtmlRenderDetails render_info); + +protected: + struct PollOption { + QString name; + int votes; + }; + typedef std::vector PollOptionList; + + QDateTime end_time; + QDateTime closed_time; + + int total_votes = 0; + + PollOptionList options; + + QString get_html_poll_options(HtmlRenderDetails render_info); +}; -- cgit v1.2.3-54-g00ecf