added bookmarks in service and models

This commit is contained in:
Nicolas Constant 2020-03-12 19:54:52 -04:00
parent 2cb2e8770e
commit 57b98e9e4f
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
4 changed files with 29 additions and 0 deletions

View File

@ -183,6 +183,20 @@ export class MastodonWrapperService {
});
}
bookmark(account: AccountInfo, status: Status): Promise<Status> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {
return this.mastodonService.bookmark(refreshedAccount, status);
});
}
unbookmark(account: AccountInfo, status: Status): Promise<Status> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {
return this.mastodonService.unbookmark(refreshedAccount, status);
});
}
getRelationships(account: AccountInfo, accountsToRetrieve: Account[]): Promise<Relationship[]> {
return this.refreshAccountIfNeeded(account)
.then((refreshedAccount: AccountInfo) => {

View File

@ -218,6 +218,18 @@ export class MastodonService {
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()
}
bookmark(account: AccountInfo, status: Status): Promise<Status> {
const route = `https://${account.instance}${this.apiRoutes.bookmarkingStatus}`.replace('{0}', status.id);
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()
}
unbookmark(account: AccountInfo, status: Status): Promise<Status> {
const route = `https://${account.instance}${this.apiRoutes.unbookmarkingStatus}`.replace('{0}', status.id);
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()
}
getRelationships(account: AccountInfo, accountsToRetrieve: Account[]): Promise<Relationship[]> {
let params = `?${this.formatArray(accountsToRetrieve.map(x => x.id.toString()), 'id')}`;

View File

@ -70,4 +70,6 @@ export class ApiRoutes {
getScheduledStatuses = '/api/v1/scheduled_statuses';
putScheduleStatus = '/api/v1/scheduled_statuses/{0}';
deleteScheduleStatus = '/api/v1/scheduled_statuses/{0}';
bookmarkingStatus = '/api/v1/statuses/{0}/bookmark';
unbookmarkingStatus = '/api/v1/statuses/{0}/unbookmark';
}

View File

@ -187,6 +187,7 @@ export interface Status {
language: string;
pinned: boolean;
muted: boolean;
bookmarked: boolean;
card: Card;
poll: Poll;