get statuses from user account

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/2/head
Maxence Lange 2018-09-20 14:20:39 +02:00
rodzic aa7a43ecac
commit edee5f2746
5 zmienionych plików z 16 dodań i 13 usunięć

2
.gitignore vendored
Wyświetl plik

@ -2,3 +2,5 @@
\.idea/ \.idea/
vendor/ vendor/
test\.json

Wyświetl plik

@ -24,7 +24,7 @@ return [
'verb' => 'GET' 'verb' => 'GET'
], ],
[ [
'name' => 'ActivityStreams#posts', 'url' => '/user/account/{accountId}/posts', 'name' => 'ActivityStreams#statuses', 'url' => '/user/account/{accountId}/statuses',
'verb' => 'GET' 'verb' => 'GET'
], ],
[ [

Wyświetl plik

@ -56,11 +56,12 @@
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
}, },
getAccountPosts: function (accountId) { getAccountStatuses: function (accountId) {
test.sendRequest('GET', {}, '/user/account/' + accountId + '/posts', test.getAccountPostsResult) test.sendRequest('GET', {}, '/user/account/' + accountId + '/statuses',
test.getAccountStatusesResult)
}, },
getAccountPostsResult: function (data) { getAccountStatusesResult: function (data) {
console.log('Your posts: ' + JSON.stringify(data)) console.log('Your posts: ' + JSON.stringify(data))
}, },
@ -76,6 +77,7 @@
refreshData: function () { refreshData: function () {
var accountId = elem.socialListAccounts.val() var accountId = elem.socialListAccounts.val()
test.getAccountFollows(accountId) test.getAccountFollows(accountId)
test.getAccountStatuses(accountId)
}, },
sendRequest: function (method, data, url, callback) { sendRequest: function (method, data, url, callback) {
@ -124,8 +126,6 @@
}) })
test.getAccounts() test.getAccounts()
// test.getAccountPosts()
} }
if (OCA.Social === undefined) { if (OCA.Social === undefined) {

Wyświetl plik

@ -117,11 +117,11 @@ class ActivityStreamsController extends Controller {
* *
* @return DataResponse * @return DataResponse
*/ */
public function posts(int $accountId): DataResponse { public function statuses(int $accountId): DataResponse {
try { try {
$account = $this->serviceAccountsService->getAccount($this->userId, $accountId); $account = $this->serviceAccountsService->getAccount($this->userId, $accountId);
$result = $this->activityStreamsService->posts($account); $result = $this->activityStreamsService->accountStatus($account);
return $this->success($result); return $this->success($result);
} catch (Exception $e) { } catch (Exception $e) {
@ -140,7 +140,7 @@ class ActivityStreamsController extends Controller {
public function follows(int $accountId): DataResponse { public function follows(int $accountId): DataResponse {
try { try {
$account = $this->serviceAccountsService->getAccount($this->userId, $accountId); $account = $this->serviceAccountsService->getAccount($this->userId, $accountId);
$result = $this->activityStreamsService->follows($account); $result = $this->activityStreamsService->accountFollows($account);
return $this->success($result); return $this->success($result);
} catch (Exception $e) { } catch (Exception $e) {

Wyświetl plik

@ -44,7 +44,7 @@ class ActivityStreamsService {
const URL_CREATE_APP = '/api/v1/apps'; const URL_CREATE_APP = '/api/v1/apps';
const URL_VERIFY_ACCOUNT = '/api/v1/accounts/verify_credentials'; const URL_VERIFY_ACCOUNT = '/api/v1/accounts/verify_credentials';
const URL_TEST = '/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_FOLLOWS = '/api/v1/accounts/:id/following';
const URL_ACCOUNT_FOLLOWERS = '/api/v1/accounts/:id/followers'; const URL_ACCOUNT_FOLLOWERS = '/api/v1/accounts/:id/followers';
@ -102,8 +102,9 @@ class ActivityStreamsService {
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
public function posts(ServiceAccount $account) { public function accountStatus(ServiceAccount $account) {
$request = new Request(self::URL_ACCOUNT_POSTS, Request::TYPE_GET); $request = new Request(self::URL_ACCOUNT_STATUSES, Request::TYPE_GET);
$request->addDataInt('id', $account->getAccountId());
return $this->request($account, $request); return $this->request($account, $request);
} }
@ -115,7 +116,7 @@ class ActivityStreamsService {
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
public function follows(ServiceAccount $account) { public function accountFollows(ServiceAccount $account) {
$request = new Request(self::URL_ACCOUNT_FOLLOWS, Request::TYPE_GET); $request = new Request(self::URL_ACCOUNT_FOLLOWS, Request::TYPE_GET);
$request->addDataInt('id', $account->getAccountId()); $request->addDataInt('id', $account->getAccountId());