tootle-linux-client/src/API/Notification.vala

48 lines
1.4 KiB
Vala
Raw Normal View History

2020-06-20 12:04:58 +02:00
public class Tootle.API.Notification : Entity, Widgetizable {
2018-04-17 14:01:55 +02:00
2020-06-20 12:04:58 +02:00
public string id { get; set; }
public API.Account account { get; set; }
2021-07-23 13:41:03 +02:00
public string? kind { get; set; default = null; }
2020-06-20 12:04:58 +02:00
public API.Status? status { get; set; default = null; }
2019-03-11 15:14:37 +01:00
2020-06-03 17:06:11 +02:00
public override Gtk.Widget to_widget () {
return new Widgets.Notification (this);
}
2021-07-23 13:41:03 +02:00
// TODO: notification actions
public virtual GLib.Notification to_toast (InstanceAccount issuer) {
string descr;
issuer.describe_kind (kind, null, out descr, account);
2019-03-11 15:14:37 +01:00
2021-07-23 13:41:03 +02:00
var toast = new GLib.Notification ( HtmlUtils.remove_tags (descr) );
if (status != null) {
var body = "";
body += HtmlUtils.remove_tags (status.content);
toast.set_body (body);
}
2019-03-11 15:14:37 +01:00
2021-07-23 13:41:03 +02:00
var icon_file = GLib.File.new_for_uri (issuer.avatar);
var icon = new FileIcon (icon_file);
toast.set_icon (icon);
2019-03-11 15:14:37 +01:00
2021-07-23 13:41:03 +02:00
// toast.add_button_with_target_value (_("Read"), "mastodon.read_notification", id);
return toast;
}
// public Soup.Message accept_follow_request () {
// var req = new Request.POST (@"/api/v1/follow_requests/$(account.id)/authorize")
// .with_account (accounts.active)
// .exec ();
// return req;
// }
// public Soup.Message reject_follow_request () {
// var req = new Request.POST (@"/api/v1/follow_requests/$(account.id)/reject")
// .with_account (accounts.active)
// .exec ();
// return req;
// }
2018-04-17 14:01:55 +02:00
}