Преглед изворни кода

Fix OPML export regression and add token in RSS link (#6160)

* OPML regression due to *shared user queries* (the XPath attributes were not exported anymore) https://github.com/FreshRSS/FreshRSS/pull/6052
* Add master token to HTML Meta RSS link and OPML link https://github.com/FreshRSS/FreshRSS/discussions/6159#discussioncomment-8678399
Alexandre Alapetite пре 2 година
родитељ
комит
5aeab896e9
3 измењених фајлова са 8 додато и 4 уклоњено
  1. 3 3
      app/Models/CategoryDAO.php
  2. 4 0
      app/layout/layout.phtml
  3. 1 1
      docs/en/users/user_queries.md

+ 3 - 3
app/Models/CategoryDAO.php

@@ -281,7 +281,7 @@ SQL;
 	public function listCategories(bool $prePopulateFeeds = true, bool $details = false): array {
 		if ($prePopulateFeeds) {
 			$sql = 'SELECT c.id AS c_id, c.name AS c_name, c.kind AS c_kind, c.`lastUpdate` AS c_last_update, c.error AS c_error, c.attributes AS c_attributes, '
-				. ($details ? 'f.* ' : 'f.id, f.name, f.url, f.kind, f.website, f.priority, f.error, f.`cache_nbEntries`, f.`cache_nbUnreads`, f.ttl ')
+				. ($details ? 'f.* ' : 'f.id, f.name, f.url, f.kind, f.website, f.priority, f.error, f.attributes, f.`cache_nbEntries`, f.`cache_nbUnreads`, f.ttl ')
 				. 'FROM `_category` c '
 				. 'LEFT OUTER JOIN `_feed` f ON f.category=c.id '
 				. 'WHERE f.priority >= :priority '
@@ -292,7 +292,7 @@ SQL;
 			if ($stm !== false && $stm->execute($values)) {
 				$res = $stm->fetchAll(PDO::FETCH_ASSOC) ?: [];
 				/** @var array<array{'c_name':string,'c_id':int,'c_kind':int,'c_last_update':int,'c_error':int|bool,'c_attributes'?:string,
-				 * 	'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'category'?:int,'website'?:string,'priority'?:int,'error'?:int|bool,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $res */
+				 * 	'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'category'?:int,'website'?:string,'priority'?:int,'error'?:int|bool,'attributes'?:string,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $res */
 				return self::daoToCategoriesPrepopulated($res);
 			} else {
 				$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
@@ -397,7 +397,7 @@ SQL;
 	/**
 	 * @param array<array{'c_name':string,'c_id':int,'c_kind':int,'c_last_update':int,'c_error':int|bool,'c_attributes'?:string,
 	 * 	'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'website'?:string,'priority'?:int,
-	 * 	'error'?:int|bool,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $listDAO
+	 * 	'error'?:int|bool,'attributes'?:string,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $listDAO
 	 * @return array<int,FreshRSS_Category>
 	 */
 	private static function daoToCategoriesPrepopulated(array $listDAO): array {

+ 4 - 0
app/layout/layout.phtml

@@ -40,6 +40,8 @@
 	if ($this->rss_title != '') {
 		$url_rss = $url_base;
 		$url_rss['a'] = 'rss';
+		$url_rss['params']['user'] = Minz_User::name();
+		$url_rss['params']['token'] = FreshRSS_Context::userConf()->token ?: null;
 		unset($url_rss['params']['rid']);
 		if (FreshRSS_Context::userConf()->since_hours_posts_per_rss) {
 			$url_rss['params']['hours'] = FreshRSS_Context::userConf()->since_hours_posts_per_rss;
@@ -49,6 +51,8 @@
 <?php } if (FreshRSS_Context::isAll() || FreshRSS_Context::isCategory() || FreshRSS_Context::isFeed()) {
 		$opml_rss = $url_base;
 		$opml_rss['a'] = 'opml';
+		$opml_rss['params']['user'] = Minz_User::name();
+		$opml_rss['params']['token'] = FreshRSS_Context::userConf()->token ?: null;
 		unset($opml_rss['params']['rid']);
 ?>
 		<link rel="outline" type="text/x-opml" title="OPML" href="<?= Minz_Url::display($opml_rss) ?>" />

+ 1 - 1
docs/en/users/user_queries.md

@@ -53,7 +53,7 @@ Some parameters can be manually added to the URL:
 ## Sharing with a master token (deprecated)
 
 Before FreshRSS 1.24, the only option to reshare an RSS output was by using a master token,
-like `https://freshrss.example.net/?a=rss&user=alice&token1234`
+like `https://freshrss.example.net/?a=rss&user=alice&token=abc123`
 
 This was mostly intended for sharing between systems controlled by the same user, and not for sharing publicly.