2023-03-17 10:18:42 +00:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-11-08 14:13:35 -05:00
|
|
|
import EmberObject from "@ember/object";
|
2020-05-13 16:23:41 -04:00
|
|
|
import I18n from "I18n";
|
2016-06-30 13:55:44 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2019-11-07 15:38:28 -06:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2016-05-18 19:27:39 +02:00
|
|
|
|
2023-03-17 10:18:42 +00:00
|
|
|
export default class ScreenedIpAddress extends EmberObject {
|
|
|
|
static findAll(filter) {
|
|
|
|
return ajax("/admin/logs/screened_ip_addresses.json", {
|
|
|
|
data: { filter },
|
|
|
|
}).then((screened_ips) =>
|
|
|
|
screened_ips.map((b) => ScreenedIpAddress.create(b))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@equal("action_name", "block") isBlocked;
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("action_name")
|
2016-05-18 19:27:39 +02:00
|
|
|
actionName(actionName) {
|
|
|
|
return I18n.t(`admin.logs.screened_ips.actions.${actionName}`);
|
2023-03-17 10:18:42 +00:00
|
|
|
}
|
2013-10-22 16:30:30 -04:00
|
|
|
|
2019-11-07 15:38:28 -06:00
|
|
|
@discourseComputed("ip_address")
|
2016-05-18 19:27:39 +02:00
|
|
|
isRange(ipAddress) {
|
|
|
|
return ipAddress.indexOf("/") > 0;
|
2023-03-17 10:18:42 +00:00
|
|
|
}
|
2013-10-22 16:30:30 -04:00
|
|
|
|
2016-05-18 19:27:39 +02:00
|
|
|
save() {
|
2016-06-30 13:55:44 -04:00
|
|
|
return ajax(
|
|
|
|
"/admin/logs/screened_ip_addresses" +
|
|
|
|
(this.id ? "/" + this.id : "") +
|
|
|
|
".json",
|
|
|
|
{
|
2013-10-24 17:18:10 -04:00
|
|
|
type: this.id ? "PUT" : "POST",
|
|
|
|
data: {
|
2019-05-27 10:15:39 +02:00
|
|
|
ip_address: this.ip_address,
|
|
|
|
action_name: this.action_name,
|
2013-10-22 16:30:30 -04:00
|
|
|
},
|
2018-06-15 17:03:24 +02:00
|
|
|
}
|
2013-10-22 16:30:30 -04:00
|
|
|
);
|
2023-03-17 10:18:42 +00:00
|
|
|
}
|
2013-10-22 16:30:30 -04:00
|
|
|
|
2016-05-18 19:27:39 +02:00
|
|
|
destroy() {
|
2019-05-27 10:42:53 +02:00
|
|
|
return ajax("/admin/logs/screened_ip_addresses/" + this.id + ".json", {
|
|
|
|
type: "DELETE",
|
|
|
|
});
|
2023-03-17 10:18:42 +00:00
|
|
|
}
|
|
|
|
}
|