modify filters
This commit is contained in:
parent
096f91cd74
commit
e4c80782f8
4 changed files with 114 additions and 12 deletions
|
@ -2,18 +2,19 @@
|
|||
namespace classes;
|
||||
|
||||
use classes\filter\gitea;
|
||||
use classes\webhook_comp\discord;
|
||||
|
||||
class webhook extends core
|
||||
{
|
||||
private $json;
|
||||
private $filter;
|
||||
private $comp;
|
||||
|
||||
public function __construct(string $json,string $filter)
|
||||
public function __construct(string $json,string $comp)
|
||||
{
|
||||
parent::__construct();
|
||||
if($json)
|
||||
{
|
||||
$this->filter = $filter;
|
||||
$this->comp = $comp;
|
||||
$this->json = json_decode($json, false);
|
||||
}
|
||||
else
|
||||
|
@ -24,13 +25,33 @@ class webhook extends core
|
|||
|
||||
public function getMessage()
|
||||
{
|
||||
if($this->filter === "gitea")
|
||||
if($this->comp === "gitea")
|
||||
{
|
||||
$filter = new gitea();
|
||||
return($filter->formatMessageToReadable($this->json->text));
|
||||
$comp = new discord($this->json);
|
||||
return($comp->readableMessage());
|
||||
}
|
||||
|
||||
return $this->json->text;
|
||||
if($this->comp === "grafana")
|
||||
{
|
||||
$comp = new grafana($this->json);
|
||||
return($comp->readableMessage());
|
||||
}
|
||||
|
||||
if(isset($this->json->text))
|
||||
{
|
||||
return $this->json->text;
|
||||
}
|
||||
|
||||
if(isset($this->json->message) && isset($this->json->imageUrl))
|
||||
{
|
||||
return $this->json->message . PHP_EOL . $this->json->imageUrl;
|
||||
}
|
||||
|
||||
if(isset($this->json->message))
|
||||
{
|
||||
return $this->json->message;
|
||||
}
|
||||
throw new \Exception("Error not compatible query!");
|
||||
}
|
||||
|
||||
public function getEventFilter()
|
||||
|
@ -48,4 +69,4 @@ class webhook extends core
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue