3838use OCP \Files \NotFoundException ;
3939use OCP \Http \Client \IClientService ;
4040use OCP \IConfig ;
41+ use OCP \Support \Subscription \IRegistry ;
4142use Psr \Log \LoggerInterface ;
4243
4344abstract class Fetcher {
@@ -54,6 +55,9 @@ abstract class Fetcher {
5455 protected $ config ;
5556 /** @var LoggerInterface */
5657 protected $ logger ;
58+ /** @var IRegistry */
59+ protected $ registry ;
60+
5761 /** @var string */
5862 protected $ fileName ;
5963 /** @var string */
@@ -67,12 +71,14 @@ public function __construct(Factory $appDataFactory,
6771 IClientService $ clientService ,
6872 ITimeFactory $ timeFactory ,
6973 IConfig $ config ,
70- LoggerInterface $ logger ) {
74+ LoggerInterface $ logger ,
75+ IRegistry $ registry ) {
7176 $ this ->appData = $ appDataFactory ->get ('appstore ' );
7277 $ this ->clientService = $ clientService ;
7378 $ this ->timeFactory = $ timeFactory ;
7479 $ this ->config = $ config ;
7580 $ this ->logger = $ logger ;
81+ $ this ->registry = $ registry ;
7682 }
7783
7884 /**
@@ -103,6 +109,12 @@ protected function fetch($ETag, $content) {
103109 ];
104110 }
105111
112+ // If we have a valid subscription key, send it to the appstore
113+ $ subscriptionKey = $ this ->config ->getAppValue ('support ' , 'subscription_key ' );
114+ if ($ this ->registry ->delegateHasValidSubscription () && $ subscriptionKey ) {
115+ $ options ['headers ' ]['X-NC-Subscription-Key ' ] = $ subscriptionKey ;
116+ }
117+
106118 $ client = $ this ->clientService ->newClient ();
107119 try {
108120 $ response = $ client ->get ($ this ->getEndpoint (), $ options );
0 commit comments