Skip to content

Commit 9c232c4

Browse files
committed
fix: webmention stats - allow empty image
1 parent b7530d0 commit 9c232c4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/WebmentionStats.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function trackMention(
2222
string $target,
2323
string $source,
2424
string $type,
25-
string $image,
25+
?string $image,
2626
string $author,
2727
string $title
2828
) {
@@ -36,6 +36,10 @@ public function trackMention(
3636

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

39+
if (is_null($image)) {
40+
$image = '';
41+
}
42+
3943
try {
4044
$uniqueHash = md5($target . $source . $type . $mentionDate);
4145
$this->indieDb->insert(
@@ -78,7 +82,7 @@ public function updateOutbox(string $pageUuid, array $target)
7882

7983
$existingEntry = $this->indieDb->select(
8084
'outbox',
81-
['id','updates', 'page_uuid'],
85+
['id', 'updates', 'page_uuid'],
8286
'WHERE page_uuid = "' . $pageUuid . '" AND target = "' . $target['url'] . '"'
8387
);
8488

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

301-
if($host === 'brid-gy.appspot.com' || $host === 'brid.gy') {
305+
if ($host === 'brid-gy.appspot.com' || $host === 'brid.gy') {
302306
$path = parse_url($webmention->mention_source, PHP_URL_PATH);
303307
$pathParts = explode('/', $path);
304308
$host = $pathParts[2];
@@ -371,7 +375,7 @@ public function getSentMentions(int $year, int $month)
371375
$pageUrl = '#';
372376
$panelUrl = '#';
373377

374-
if(isset($page)) {
378+
if (isset($page)) {
375379
$pageTitle = $page->title()->value();
376380
$pageUrl = $page->url();
377381
$panelUrl = $page->panel()->url();
@@ -391,7 +395,10 @@ public function getSentMentions(int $year, int $month)
391395
}
392396

393397
$targets[$webmention->page_uuid]['entries'][] = [
394-
'url' => $webmention->target, 'status' => $webmention->status, 'updates' => $webmention->updates];
398+
'url' => $webmention->target,
399+
'status' => $webmention->status,
400+
'updates' => $webmention->updates
401+
];
395402
}
396403

397404
$targets = array_values($targets);

0 commit comments

Comments
 (0)