mirror of
https://github.com/NicolasConstant/sengi
synced 2025-02-03 03:47:35 +01:00
added bookmarks in service and models
This commit is contained in:
parent
2cb2e8770e
commit
57b98e9e4f
@ -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) => {
|
||||
|
@ -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')}`;
|
||||
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ export interface Status {
|
||||
language: string;
|
||||
pinned: boolean;
|
||||
muted: boolean;
|
||||
bookmarked: boolean;
|
||||
card: Card;
|
||||
poll: Poll;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user