summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-09-20 14:20:39 +0200
committerMaxence Lange <maxence@artificial-owl.com>2018-09-20 14:20:39 +0200
commitedee5f2746c507797b6f168e222be03b14afed7d (patch)
tree45f039be8603b564f1874312efe1175b65d904bd
parentaa7a43ecac373ab5f969ab760b3c2bc7da678dfd (diff)
get statuses from user account
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--.gitignore2
-rw-r--r--appinfo/routes.php2
-rw-r--r--js/test.js10
-rw-r--r--lib/Controller/ActivityStreamsController.php6
-rw-r--r--lib/Service/ActivityStreamsService.php9
5 files changed, 16 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index f6400d9c..8878b94c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
\.idea/
vendor/
+
+test\.json
diff --git a/appinfo/routes.php b/appinfo/routes.php
index e2ecb5db..a5276275 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -24,7 +24,7 @@ return [
'verb' => 'GET'
],
[
- 'name' => 'ActivityStreams#posts', 'url' => '/user/account/{accountId}/posts',
+ 'name' => 'ActivityStreams#statuses', 'url' => '/user/account/{accountId}/statuses',
'verb' => 'GET'
],
[
diff --git a/js/test.js b/js/test.js
index 212485a3..f0c080eb 100644
--- a/js/test.js
+++ b/js/test.js
@@ -56,11 +56,12 @@
console.log(JSON.stringify(data))
},
- getAccountPosts: function (accountId) {
- test.sendRequest('GET', {}, '/user/account/' + accountId + '/posts', test.getAccountPostsResult)
+ getAccountStatuses: function (accountId) {
+ test.sendRequest('GET', {}, '/user/account/' + accountId + '/statuses',
+ test.getAccountStatusesResult)
},
- getAccountPostsResult: function (data) {
+ getAccountStatusesResult: function (data) {
console.log('Your posts: ' + JSON.stringify(data))
},
@@ -76,6 +77,7 @@
refreshData: function () {
var accountId = elem.socialListAccounts.val()
test.getAccountFollows(accountId)
+ test.getAccountStatuses(accountId)
},
sendRequest: function (method, data, url, callback) {
@@ -124,8 +126,6 @@
})
test.getAccounts()
-
-// test.getAccountPosts()
}
if (OCA.Social === undefined) {
diff --git a/lib/Controller/ActivityStreamsController.php b/lib/Controller/ActivityStreamsController.php
index 912384f3..3e32197a 100644
--- a/lib/Controller/ActivityStreamsController.php
+++ b/lib/Controller/ActivityStreamsController.php
@@ -117,11 +117,11 @@ class ActivityStreamsController extends Controller {
*
* @return DataResponse
*/
- public function posts(int $accountId): DataResponse {
+ public function statuses(int $accountId): DataResponse {
try {
$account = $this->serviceAccountsService->getAccount($this->userId, $accountId);
- $result = $this->activityStreamsService->posts($account);
+ $result = $this->activityStreamsService->accountStatus($account);
return $this->success($result);
} catch (Exception $e) {
@@ -140,7 +140,7 @@ class ActivityStreamsController extends Controller {
public function follows(int $accountId): DataResponse {
try {
$account = $this->serviceAccountsService->getAccount($this->userId, $accountId);
- $result = $this->activityStreamsService->follows($account);
+ $result = $this->activityStreamsService->accountFollows($account);
return $this->success($result);
} catch (Exception $e) {
diff --git a/lib/Service/ActivityStreamsService.php b/lib/Service/ActivityStreamsService.php
index 4091877f..9a76a31c 100644
--- a/lib/Service/ActivityStreamsService.php
+++ b/lib/Service/ActivityStreamsService.php
@@ -44,7 +44,7 @@ class ActivityStreamsService {
const URL_CREATE_APP = '/api/v1/apps';
const URL_VERIFY_ACCOUNT = '/api/v1/accounts/verify_credentials';
const URL_TEST = '/api/v1/accounts/verify_credentials';
- const URL_ACCOUNT_POSTS = '/api/v1/accounts/verify_credentials';
+ const URL_ACCOUNT_STATUSES = '/api/v1/accounts/:id/statuses';
const URL_ACCOUNT_FOLLOWS = '/api/v1/accounts/:id/following';
const URL_ACCOUNT_FOLLOWERS = '/api/v1/accounts/:id/followers';
@@ -102,8 +102,9 @@ class ActivityStreamsService {
* @return array
* @throws Exception
*/
- public function posts(ServiceAccount $account) {
- $request = new Request(self::URL_ACCOUNT_POSTS, Request::TYPE_GET);
+ public function accountStatus(ServiceAccount $account) {
+ $request = new Request(self::URL_ACCOUNT_STATUSES, Request::TYPE_GET);
+ $request->addDataInt('id', $account->getAccountId());
return $this->request($account, $request);
}
@@ -115,7 +116,7 @@ class ActivityStreamsService {
* @return array
* @throws Exception
*/
- public function follows(ServiceAccount $account) {
+ public function accountFollows(ServiceAccount $account) {
$request = new Request(self::URL_ACCOUNT_FOLLOWS, Request::TYPE_GET);
$request->addDataInt('id', $account->getAccountId());