Skip to content

Commit b44d6d2

Browse files
committed
Fix: Use nickname fallback
1 parent e856ba3 commit b44d6d2

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

includes/Handler/class-mf2.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ protected function set_property_author( $properties ) {
112112
foreach ( array( 'name', 'nickname', 'given-name', 'family-name', 'url', 'email', 'photo' ) as $prop ) {
113113
$author[ $prop ] = $this->get_plaintext( $properties, $prop );
114114
}
115+
116+
// If name is not available, use nickname or the combination of given name and family name as fallback
117+
if ( empty( $author['name'] ) ) {
118+
if ( ! empty( $author['nickname'] ) ) {
119+
$author['name'] = $author['nickname'];
120+
} elseif ( ! empty( $author['given-name'] ) || ! empty( $author['family-name'] ) ) {
121+
$author['name'] = implode( ' ', array_filter( array( $author['given-name'], $author['family-name'] ) ) );
122+
}
123+
}
115124
}
116125

117126
$this->webmention_item->add_author( array_filter( $author ) );
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="refresh" content="0;url=https://aseachange.com/@elena/statuses/01JZNGNC6TXX9QYZ3Q13ZK31C7">
6+
<title><p><span class="h-card"><a href="https://mastodon.social/@pfefferle" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>pfefferle</span></a></span> such a fast solution wow! 🏆✨ congrats all</p><p><span class="h-card"><a href="https://social.wake.st/@liaizon" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>liaizon</span></a></span> <span class="h-card"><a href="https://snac.rohrmoser.name/social/wake_st" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>wake_st</span></a></span> <span class="h-card"><a href="https://notiz.blog/author/matthias-pfefferle/" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>pfefferle</span></a></span> <span class="h-card"><a href="https://comam.es/snac/grunfink" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>grunfink</span></a></span></p></title>
7+
<style type="text/css">
8+
body {
9+
display: none;
10+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
11+
}
12+
.p-uid {
13+
display: none;
14+
}
15+
.u-photo {
16+
max-width: 50px;
17+
border-radius: 4px;
18+
}
19+
.e-content {
20+
margin-top: 10px;
21+
font-size: 1.3em;
22+
}
23+
</style>
24+
</head>
25+
<article class="h-entry">
26+
<span class="p-uid">https://aseachange.com/users/elena/statuses/01JZNGNC6TXX9QYZ3Q13ZK31C7</span>
27+
28+
<time class="dt-published" datetime="2025-07-08T17:17:15+00:00">2025-07-08T17:17:15+00:00</time>
29+
30+
<span class="p-author h-card">
31+
<data class="p-uid" value="https://aseachange.com/users/elena"></data>
32+
<data class="p-numeric-id" value="113695878928179087"></data>
33+
<a class="p-name u-url" href="https://aseachange.com/@elena">Elena Rossini on GoToSocial ⁂</a>
34+
<a class="u-url" href="https://news.elenarossini.com"></a>
35+
<a class="u-url" href="https://elena.social"></a>
36+
<span class="p-nickname">elena</span>
37+
<img class="u-photo" src="https://files.mastodon.social/cache/accounts/avatars/113/695/878/928/179/087/original/edadee646dc7593c.jpeg" alt="" />
38+
</span>
39+
40+
<a title="aseachange.com/@elena/statuses/01JZNGNC6TXX9QYZ3Q13ZK31C7" class="u-url" href="https://aseachange.com/@elena/statuses/01JZNGNC6TXX9QYZ3Q13ZK31C7">aseachange.com/@elena/statuse...</a>
41+
<div class="e-content p-name">
42+
43+
<p><span class="h-card"><a href="https://mastodon.social/@pfefferle" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>pfefferle</span></a></span> such a fast solution wow! 🏆✨ congrats all</p><p><span class="h-card"><a href="https://social.wake.st/@liaizon" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>liaizon</span></a></span> <span class="h-card"><a href="https://snac.rohrmoser.name/social/wake_st" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>wake_st</span></a></span> <span class="h-card"><a href="https://notiz.blog/author/matthias-pfefferle/" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>pfefferle</span></a></span> <span class="h-card"><a href="https://comam.es/snac/grunfink" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>grunfink</span></a></span></p>
44+
</div>
45+
46+
47+
48+
49+
<span class="u-category h-card">
50+
<data class="p-uid" value="https://mastodon.social/users/pfefferle"></data>
51+
<a class="p-name u-url" href="https://mastodon.social/@pfefferle">pfefferle</a>
52+
53+
54+
</span>
55+
56+
<span class="u-category h-card">
57+
<data class="p-uid" value="https://social.wake.st/users/liaizon"></data>
58+
<a class="p-name u-url" href="https://social.wake.st/@liaizon">liaizon</a>
59+
60+
61+
</span>
62+
63+
<span class="u-category h-card">
64+
<data class="p-uid" value="https://snac.rohrmoser.name/social/wake_st"></data>
65+
<a class="p-name u-url" href="https://snac.rohrmoser.name/social/wake_st">wake_st</a>
66+
67+
68+
</span>
69+
70+
<span class="u-category h-card">
71+
<data class="p-uid" value="https://notiz.blog/author/matthias-pfefferle/"></data>
72+
<a class="p-name u-url" href="https://notiz.blog/author/matthias-pfefferle/">pfefferle</a>
73+
74+
75+
</span>
76+
77+
<span class="u-category h-card">
78+
<data class="p-uid" value="https://comam.es/snac/grunfink"></data>
79+
<a class="p-name u-url" href="https://comam.es/snac/grunfink">grunfink</a>
80+
81+
82+
</span>
83+
84+
<a class="u-in-reply-to" href="https://mastodon.social/web/statuses/114818494113762375"></a>
85+
<a class="u-in-reply-to" href="tag:mastodon.social,2013:114818494113762375"></a>
86+
87+
88+
</article>
89+
90+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"author": {
3+
"name": "elena",
4+
"url": "https://aseachange.com/users/elena"
5+
},
6+
"response_type": "mention"
7+
}

0 commit comments

Comments
 (0)