From f859d33ae3b80dae7229fac296f2e5782346a7b8 Mon Sep 17 00:00:00 2001 From: Tanmay Patil Date: Mon, 9 Oct 2023 13:28:41 +0530 Subject: Use install command instead of cp --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8be2206..59e55d1 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ CC = gcc CFLAGS = -Wall -std=gnu99 SOURCES = $(addprefix src/, whatfiles.c attach.c utilities.c hashmap.c strings.c) +INSTALL = /usr/bin/install -c + ARCH = $(shell uname -m) ifeq ($(findstring arm,$(ARCH)), arm) ARCH_DIR = arm32 @@ -22,8 +24,8 @@ bin/whatfiles: $(SOURCES) # utils -install: - cp ./bin/whatfiles /usr/local/bin/whatfiles +install: bin/whatfiles + ${INSTALL} ./bin/whatfiles /usr/local/bin/whatfiles clean: rm -rf bin/* -- cgit v1.2.3 id='header'> cgit logo index : nextcloud-news
Mirror of https://github.com/nextcloud/newsmatthias
summaryrefslogtreecommitdiffstats
path: root/controller/feedapicontroller.php
blob: 33a9cbb7fce73c51b2b6723129429af96b7f9a4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
 * ownCloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Alessandro Cosentino <cosenal@gmail.com>
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 * @copyright Alessandro Cosentino 2012
 * @copyright Bernhard Posselt 2012, 2014
 */

namespace OCA\News\Controller;

use \OCP\IRequest;
use \OCP\ILogger;
use \OCP\AppFramework\ApiController;
use \OCP\AppFramework\Http;

use \OCA\News\Service\FeedService;
use \OCA\News\Service\ItemService;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Service\ServiceConflictException;


class FeedApiController extends ApiController {

	use JSONHttpError;

	private $itemService;
	private $feedService;
	private $userId;
	private $logger;
	private $loggerParams;
	private $serializer;

	public function __construct($appName,
	                            IRequest $request,
	                            FeedService $feedService,
	                            ItemService $itemService,
	                            ILogger $logger,
	                            $userId,
	                            $loggerParams){
		parent::__construct($appName, $request);
		$this->feedService = $feedService;
		$this->itemService = $itemService;
		$this->userId = $userId;
		$this->logger = $logger;
		$this->loggerParams = $loggerParams;
		$this->serializer = new EntityApiSerializer('feeds');
	}


	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 * @CORS
	 */
	public function index() {

		$result = [
			'starredCount' => $this->itemService->starredCount($this->userId),
			'feeds' => $this->feedService->findAll($this->userId)
		];


		try {
			$result['newestItemId'] = $this->itemService->getNewestItemId($this->userId);

		// in case there are no items, ignore
		} catch(ServiceNotFoundException $ex) {}

		return $this->serializer->serialize($result);
	}


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param string $url
     * @param int $folderId
     * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
     */
	public function create($url, $folderId=0) {
		try {
			$this->feedService->purgeDeleted($this->userId, false);

			$feed = $this->feedService->create($url, $folderId, $this->userId);
			$result = ['feeds' => [$feed]];

			try {
				$result['newestItemId'] = $this->itemService->getNewestItemId($this->userId);

			// in case there are no items, ignore
			} catch(ServiceNotFoundException $ex) {}

			return $this->serializer->serialize($result);

		} catch(ServiceConflictException $ex) {
			return $this->error($ex, Http::STATUS_CONFLICT);
		} catch(ServiceNotFoundException $ex) {
			return $this->error($ex, Http::STATUS_NOT_FOUND);
		}
	}


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
	public function delete($feedId) {
		try {
			$this->feedService->delete($feedId, $this->userId);
		} catch(ServiceNotFoundException $ex) {
			return $this->error($ex, Http::STATUS_NOT_FOUND);
		}

        return [];
	}


	/**
	 * @NoAdminRequired
	 * @NoCSRFRequired
	 * @CORS
	 *
	 * @param int $feedId
	 * @param int $newestItemId
	 */
	public function read($feedId, $newestItemId) {
		$this->itemService->readFeed($feedId, $newestItemId, $this->userId);
	}


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @param int $folderId
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
	public function move($feedId, $folderId) {
		try {
			$this->feedService->move($feedId, $folderId, $this->userId);
		} catch(ServiceNotFoundException $ex) {
			return $this->error($ex, Http::STATUS_NOT_FOUND);
		}

        return [];
	}


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @param string $feedTitle
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
	public function rename($feedId, $feedTitle) {
		try {
			$this->feedService->rename($feedId, $feedTitle, $this->userId);
		} catch(ServiceNotFoundException $ex) {
			return $this->error($ex, Http::STATUS_NOT_FOUND);
		}

        return [];
	}


	/**
	 * @NoCSRFRequired
	 * @CORS
	 */
	public function fromAllUsers() {
		$feeds = $this->feedService->findAllFromAllUsers();
		$result = ['feeds' => []];

		foreach ($feeds as $feed) {
			$result['feeds'][] = [
				'id' => $feed->getId(),
				'userId' => $feed->getUserId()
			];
		}

		return $result;
	}


	/**
	 * @NoCSRFRequired
	 *
	 * @param string $userId
	 * @param int $feedId
	 */
	public function update($userId, $feedId) {
		try {
			$this->feedService->update($feedId, $userId);
		// ignore update failure (feed could not be reachable etc, we don't care)
		} catch(\Exception $ex) {
			$this->logger->debug('Could not update feed ' . $ex->getMessage(),
					$this->loggerParams);
		}
	}


}