Skip to content

Commit

Permalink
fix: webmention stats - allow empty image
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricerenck committed Nov 28, 2024
1 parent b7530d0 commit 9c232c4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/WebmentionStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function trackMention(
string $target,
string $source,
string $type,
string $image,
?string $image,
string $author,
string $title
) {
Expand All @@ -36,6 +36,10 @@ public function trackMention(

$mentionDate = $this->indieDb->getFormattedDate();

if (is_null($image)) {
$image = '';
}

try {
$uniqueHash = md5($target . $source . $type . $mentionDate);
$this->indieDb->insert(
Expand Down Expand Up @@ -78,7 +82,7 @@ public function updateOutbox(string $pageUuid, array $target)

$existingEntry = $this->indieDb->select(
'outbox',
['id','updates', 'page_uuid'],
['id', 'updates', 'page_uuid'],
'WHERE page_uuid = "' . $pageUuid . '" AND target = "' . $target['url'] . '"'
);

Expand Down Expand Up @@ -298,7 +302,7 @@ public function getSourceHosts(int $year, int $month)
$host = parse_url($webmention->mention_source, PHP_URL_HOST);
$userHandle = $host;

if($host === 'brid-gy.appspot.com' || $host === 'brid.gy') {
if ($host === 'brid-gy.appspot.com' || $host === 'brid.gy') {
$path = parse_url($webmention->mention_source, PHP_URL_PATH);
$pathParts = explode('/', $path);
$host = $pathParts[2];
Expand Down Expand Up @@ -371,7 +375,7 @@ public function getSentMentions(int $year, int $month)
$pageUrl = '#';
$panelUrl = '#';

if(isset($page)) {
if (isset($page)) {
$pageTitle = $page->title()->value();
$pageUrl = $page->url();
$panelUrl = $page->panel()->url();
Expand All @@ -391,7 +395,10 @@ public function getSentMentions(int $year, int $month)
}

$targets[$webmention->page_uuid]['entries'][] = [
'url' => $webmention->target, 'status' => $webmention->status, 'updates' => $webmention->updates];
'url' => $webmention->target,
'status' => $webmention->status,
'updates' => $webmention->updates
];
}

$targets = array_values($targets);
Expand Down

0 comments on commit 9c232c4

Please sign in to comment.