Tooth/src/API/Notification.vala

49 lines
1.5 KiB
Vala
Raw Normal View History

2022-11-13 20:57:43 +00:00
public class Tooth.API.Notification : Entity, Widgetizable {
2018-04-17 12:01:55 +00:00
2020-06-20 10:04:58 +00:00
public string id { get; set; }
public API.Account account { get; set; }
2021-07-23 11:41:03 +00:00
public string? kind { get; set; default = null; }
2020-06-20 10:04:58 +00:00
public API.Status? status { get; set; default = null; }
2019-03-11 14:14:37 +00:00
2020-06-03 15:06:11 +00:00
public override Gtk.Widget to_widget () {
return new Widgets.Notification (this);
}
2021-07-23 11:41:03 +00:00
// TODO: notification actions
public virtual GLib.Notification to_toast (InstanceAccount issuer) {
string descr;
2022-11-17 18:32:26 +00:00
string descr_url;
issuer.describe_kind (kind, null, out descr, account, out descr_url);
2019-03-11 14:14:37 +00:00
2021-07-23 11:41:03 +00: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 14:14:37 +00:00
var icon_file = GLib.File.new_for_uri (account.avatar);
2021-07-23 11:41:03 +00:00
var icon = new FileIcon (icon_file);
toast.set_icon (icon);
2019-03-11 14:14:37 +00:00
2021-07-23 11:41:03 +00: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 12:01:55 +00:00
}