mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Wall: Add RSS output
Currently it doesn't support Images and Reposts, but in future i'll do that. Reversly related to #437 XD git status! ALSO IT'S TIME TO UPDATE COMPOSER git status!
This commit is contained in:
parent
4d6af6d28e
commit
b7b1a9b31c
4 changed files with 123 additions and 24 deletions
|
@ -5,6 +5,9 @@ use openvk\Web\Models\Entities\Notifications\{RepostNotification, WallPostNotifi
|
||||||
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums};
|
use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums};
|
||||||
use Chandler\Database\DatabaseConnection;
|
use Chandler\Database\DatabaseConnection;
|
||||||
use Nette\InvalidStateException as ISE;
|
use Nette\InvalidStateException as ISE;
|
||||||
|
use Bhaktaraz\RSSGenerator\Item;
|
||||||
|
use Bhaktaraz\RSSGenerator\Feed;
|
||||||
|
use Bhaktaraz\RSSGenerator\Channel;
|
||||||
|
|
||||||
final class WallPresenter extends OpenVKPresenter
|
final class WallPresenter extends OpenVKPresenter
|
||||||
{
|
{
|
||||||
|
@ -83,6 +86,49 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
$this->renderWall($user, true);
|
$this->renderWall($user, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderRSS(int $user): void
|
||||||
|
{
|
||||||
|
if(false)
|
||||||
|
exit("Ошибка доступа: " . (string) random_int(0, 255));
|
||||||
|
|
||||||
|
$owner = ($user < 0 ? (new Clubs) : (new Users))->get(abs($user));
|
||||||
|
if(is_null($this->user)) {
|
||||||
|
$canPost = false;
|
||||||
|
} else if($user > 0) {
|
||||||
|
if(!$owner->isBanned())
|
||||||
|
$canPost = $owner->getPrivacyPermission("wall.write", $this->user->identity);
|
||||||
|
else
|
||||||
|
$this->flashFail("err", tr("error"), "Ошибка доступа");
|
||||||
|
} else if($user < 0) {
|
||||||
|
if($owner->canBeModifiedBy($this->user->identity))
|
||||||
|
$canPost = true;
|
||||||
|
else
|
||||||
|
$canPost = $owner->canPost();
|
||||||
|
} else {
|
||||||
|
$canPost = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = iterator_to_array($this->posts->getPostsFromUsersWall($user));
|
||||||
|
|
||||||
|
$feed = new Feed();
|
||||||
|
|
||||||
|
$channel = new Channel();
|
||||||
|
$channel->title(OPENVK_ROOT_CONF['openvk']['appearance']['name'])->url(ovk_scheme(true))->appendTo($feed);
|
||||||
|
|
||||||
|
foreach($posts as $post) {
|
||||||
|
$item = new Item();
|
||||||
|
$item
|
||||||
|
->title($post->getOwner()->getCanonicalName())
|
||||||
|
->description($post->getText())
|
||||||
|
->url(ovk_scheme(true)."/wall{$post->getPrettyId()}")
|
||||||
|
->pubDate($post->getPublicationTime()->timestamp())
|
||||||
|
->appendTo($channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Content-Type: application/rss+xml");
|
||||||
|
exit($feed);
|
||||||
|
}
|
||||||
|
|
||||||
function renderFeed(): void
|
function renderFeed(): void
|
||||||
{
|
{
|
||||||
$this->assertUserLoggedIn();
|
$this->assertUserLoggedIn();
|
||||||
|
|
|
@ -105,6 +105,8 @@ routes:
|
||||||
hashTag: ".++"
|
hashTag: ".++"
|
||||||
- url: "/wall{num}"
|
- url: "/wall{num}"
|
||||||
handler: "Wall->wall"
|
handler: "Wall->wall"
|
||||||
|
- url: "/wall{num}/rss"
|
||||||
|
handler: "Wall->rss"
|
||||||
- url: "/wall{num}/makePost"
|
- url: "/wall{num}/makePost"
|
||||||
handler: "Wall->makePost"
|
handler: "Wall->makePost"
|
||||||
- url: "/wall{num}_{num}"
|
- url: "/wall{num}_{num}"
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
"lfkeitel/phptotp": "dev-master",
|
"lfkeitel/phptotp": "dev-master",
|
||||||
"chillerlan/php-qrcode": "dev-main",
|
"chillerlan/php-qrcode": "dev-main",
|
||||||
"vearutop/php-obscene-censor-rus": "dev-master",
|
"vearutop/php-obscene-censor-rus": "dev-master",
|
||||||
"erusev/parsedown": "dev-master"
|
"erusev/parsedown": "dev-master",
|
||||||
|
"bhaktaraz/php-rss-generator": "dev-master"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev"
|
"minimum-stability": "dev"
|
||||||
}
|
}
|
||||||
|
|
92
composer.lock
generated
92
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "3816f5fbf2c78a3e252637476cd2ae08",
|
"content-hash": "2c94032cae911ca438bbcfc46c346961",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "al/emoji-detector",
|
"name": "al/emoji-detector",
|
||||||
|
@ -52,6 +52,55 @@
|
||||||
},
|
},
|
||||||
"time": "2020-06-26T09:10:17+00:00"
|
"time": "2020-06-26T09:10:17+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "bhaktaraz/php-rss-generator",
|
||||||
|
"version": "dev-master",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/bhaktaraz/php-rss-generator.git",
|
||||||
|
"reference": "53cf11db18d87e65973e6df453fb8c1382e5a3bd"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/bhaktaraz/php-rss-generator/zipball/53cf11db18d87e65973e6df453fb8c1382e5a3bd",
|
||||||
|
"reference": "53cf11db18d87e65973e6df453fb8c1382e5a3bd",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"default-branch": true,
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Bhaktaraz\\RSSGenerator\\": "Source/Bhaktaraz/RSSGenerator/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bhaktaraz Bhatta",
|
||||||
|
"email": "bhattabhakta@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Simple RSS generator library for PHP 5.5 or later.",
|
||||||
|
"homepage": "https://github.com/bhaktaraz/php-rss-generator",
|
||||||
|
"keywords": [
|
||||||
|
"Facebook product feed generator",
|
||||||
|
"feed",
|
||||||
|
"generator",
|
||||||
|
"rss",
|
||||||
|
"writer"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/bhaktaraz/php-rss-generator/issues",
|
||||||
|
"source": "https://github.com/bhaktaraz/php-rss-generator/tree/master"
|
||||||
|
},
|
||||||
|
"time": "2021-03-15T10:59:47+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "chillerlan/php-qrcode",
|
"name": "chillerlan/php-qrcode",
|
||||||
"version": "dev-main",
|
"version": "dev-main",
|
||||||
|
@ -520,12 +569,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"GuzzleHttp\\Psr7\\": "src/"
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"src/functions_include.php"
|
"src/functions_include.php"
|
||||||
]
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"GuzzleHttp\\Psr7\\": "src/"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -600,12 +649,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/JamesHeinrich/getID3.git",
|
"url": "https://github.com/JamesHeinrich/getID3.git",
|
||||||
"reference": "46346ff3bea96a63f1a1d58ee4eabc79471d0ec8"
|
"reference": "2279f7caca2d761dfc580dd02b401e7a1ff69dfe"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/46346ff3bea96a63f1a1d58ee4eabc79471d0ec8",
|
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/2279f7caca2d761dfc580dd02b401e7a1ff69dfe",
|
||||||
"reference": "46346ff3bea96a63f1a1d58ee4eabc79471d0ec8",
|
"reference": "2279f7caca2d761dfc580dd02b401e7a1ff69dfe",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -660,7 +709,7 @@
|
||||||
"issues": "https://github.com/JamesHeinrich/getID3/issues",
|
"issues": "https://github.com/JamesHeinrich/getID3/issues",
|
||||||
"source": "https://github.com/JamesHeinrich/getID3/tree/master"
|
"source": "https://github.com/JamesHeinrich/getID3/tree/master"
|
||||||
},
|
},
|
||||||
"time": "2022-01-03T16:59:52+00:00"
|
"time": "2022-02-03T17:07:51+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "komeiji-satori/curl",
|
"name": "komeiji-satori/curl",
|
||||||
|
@ -1069,12 +1118,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Intl\\Idn\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"bootstrap.php"
|
"bootstrap.php"
|
||||||
]
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Intl\\Idn\\": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -1154,12 +1203,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"bootstrap.php"
|
"bootstrap.php"
|
||||||
],
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
|
||||||
|
},
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"Resources/stubs"
|
"Resources/stubs"
|
||||||
]
|
]
|
||||||
|
@ -1235,12 +1284,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Php72\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"bootstrap.php"
|
"bootstrap.php"
|
||||||
]
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Php72\\": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -1512,7 +1561,8 @@
|
||||||
"lfkeitel/phptotp": 20,
|
"lfkeitel/phptotp": 20,
|
||||||
"chillerlan/php-qrcode": 20,
|
"chillerlan/php-qrcode": 20,
|
||||||
"vearutop/php-obscene-censor-rus": 20,
|
"vearutop/php-obscene-censor-rus": 20,
|
||||||
"erusev/parsedown": 20
|
"erusev/parsedown": 20,
|
||||||
|
"bhaktaraz/php-rss-generator": 20
|
||||||
},
|
},
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
|
|
Loading…
Reference in a new issue