some sanity checks
Some checks failed
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled

This commit is contained in:
2024-06-21 13:20:24 +02:00
parent f5e7e7de5a
commit be2885e31d
2 changed files with 20 additions and 5 deletions

View File

@ -10,7 +10,7 @@
class OurHandler : public WinToastLib::IWinToastHandler {
public:
virtual ~OurHandler(void) {
virtual ~OurHandler(void) override {
}
protected: // wintoast
@ -58,16 +58,30 @@ bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
return false;
}
const auto& text = e.e.get<Message::Components::MessageText>().text;
if (text.empty()) {
return false;
}
const auto sender_c = e.e.get<Message::Components::ContactFrom>().c;
if (_cr.all_of<Contact::Components::TagSelfStrong>(sender_c)) {
return false;
}
if (!_cr.all_of<
Contact::Components::Name
>(sender_c)) {
return false;
}
std::string title {
_cr.get<Contact::Components::Name>(sender_c).name
};
if (title.empty()) {
return false;
}
auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02);
templ.setTextField(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(
@ -77,7 +91,7 @@ bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
);
templ.setTextField(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(
e.e.get<Message::Components::MessageText>().text
text
),
WinToastLib::WinToastTemplate::SecondLine
);