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; }
|
|
|
|
public API.NotificationType kind { get; set; }
|
2020-05-29 14:19:35 +02:00
|
|
|
public string created_at { get; set; }
|
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);
|
|
|
|
}
|
|
|
|
|
2018-07-14 10:37:41 +02:00
|
|
|
public Soup.Message? dismiss () {
|
2020-05-29 14:19:35 +02:00
|
|
|
if (kind == NotificationType.WATCHLIST) {
|
|
|
|
if (accounts.active.cached_notifications.remove (this))
|
2018-10-30 16:57:37 +01:00
|
|
|
accounts.save ();
|
2018-07-14 10:37:41 +02:00
|
|
|
return null;
|
2018-10-30 16:57:37 +01:00
|
|
|
}
|
2019-03-11 15:14:37 +01:00
|
|
|
|
2020-05-29 14:19:35 +02:00
|
|
|
if (kind == NotificationType.FOLLOW_REQUEST)
|
2018-05-09 17:32:53 +02:00
|
|
|
return reject_follow_request ();
|
2019-03-11 15:14:37 +01:00
|
|
|
|
2020-05-29 14:19:35 +02:00
|
|
|
var req = new Request.POST ("/api/v1/notifications/dismiss")
|
|
|
|
.with_account (accounts.active)
|
2020-06-20 12:04:58 +02:00
|
|
|
.with_param ("id", id)
|
2020-05-29 14:19:35 +02:00
|
|
|
.exec ();
|
|
|
|
return req;
|
2018-05-09 17:32:53 +02:00
|
|
|
}
|
2019-03-11 15:14:37 +01:00
|
|
|
|
2018-05-09 17:32:53 +02:00
|
|
|
public Soup.Message accept_follow_request () {
|
2020-05-29 14:19:35 +02:00
|
|
|
var req = new Request.POST (@"/api/v1/follow_requests/$(account.id)/authorize")
|
|
|
|
.with_account (accounts.active)
|
|
|
|
.exec ();
|
|
|
|
return req;
|
2018-05-09 17:32:53 +02:00
|
|
|
}
|
2019-03-11 15:14:37 +01:00
|
|
|
|
2018-05-09 17:32:53 +02:00
|
|
|
public Soup.Message reject_follow_request () {
|
2020-05-29 14:19:35 +02:00
|
|
|
var req = new Request.POST (@"/api/v1/follow_requests/$(account.id)/reject")
|
|
|
|
.with_account (accounts.active)
|
|
|
|
.exec ();
|
|
|
|
return req;
|
2018-05-09 17:32:53 +02:00
|
|
|
}
|
2018-04-17 14:01:55 +02:00
|
|
|
|
|
|
|
}
|