kopia lustrzana https://github.com/nextcloud/social
get statuses from user account
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/2/head
rodzic
aa7a43ecac
commit
edee5f2746
|
@ -2,3 +2,5 @@
|
|||
\.idea/
|
||||
|
||||
vendor/
|
||||
|
||||
test\.json
|
||||
|
|
|
@ -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'
|
||||
],
|
||||
[
|
||||
|
|
10
js/test.js
10
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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue