Add support for reading polls

merge-requests/5/head
Terence Eden 2024-03-03 10:02:43 +00:00
rodzic 6d46fa45c6
commit 571b6fbe7c
1 zmienionych plików z 29 dodań i 9 usunięć

Wyświetl plik

@ -1289,14 +1289,41 @@ HTML;
$replyTo = "";
}
// Check to see if there is a Content Warning
// Has the user has been specifically CC'd?
if ( isset( $object["cc"] ) ) {
$reply = in_array( "https://{$server}/{$username}", $object["cc"] );
} else {
$reply = false;
}
// Is there is a Content Warning?
if ( isset( $object["summary"] ) ) {
$summary = $object["summary"];
$summary = strip_tags( $summary, $allowed_elements );
$content = "<details><summary>{$summary}</summary>{$content}</details>";
}
// Is there a poll?
// ActivityPub specification - https://www.w3.org/TR/activitystreams-vocabulary/#questions
// Mastodon documentation - https://docs.joinmastodon.org/spec/activitypub/#Question
if ( isset( $object["oneOf"] ) ) {
foreach ( $object["oneOf"] as $pollOption ) {
$pollOptionName = $pollOption["name"];
$pollOptionValue = $pollOption["replies"]["totalItems"];
$content .= "<br>{$pollOptionName}: $pollOptionValue";
}
}
if ( isset( $object["anyOf"] ) ) {
foreach ( $object["anyOf"] as $pollOption ) {
$pollOptionName = htmlspecialchars( $pollOption["name"] );
$pollOptionValue = $pollOption["replies"]["totalItems"];
$content .= "<br>{$pollOptionName}: $pollOptionValue";
}
}
// Add any images
if ( isset( $object["attachment"] ) ) {
foreach ( $object["attachment"] as $attachment ) {
@ -1318,13 +1345,6 @@ HTML;
}
}
// Check to see if the user has been specifically CC'd
if ( isset( $object["cc"] ) ) {
$reply = in_array( "https://{$server}/{$username}", $object["cc"] );
} else {
$reply = false;
}
// What sort of message is this?
"Create" == $type ? $verb = "wrote" : $verb = "updated";
if ( $reply ) {