added hide boosts, block domain, fix #487
This commit is contained in:
parent
a0cb240446
commit
8c9685045e
|
@ -27,7 +27,13 @@
|
|||
<ng-template contextMenuItem (execute)="unmuteConversation()" *ngIf="statusWrapper && isOwnerSelected && displayedStatus.muted">
|
||||
Unmute conversation
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="hideBoosts()" *ngIf="!isOwnerSelected && this.relationship && this.relationship.following && this.relationship.showing_reblogs">
|
||||
Hide boosts from @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="unhideBoosts()" *ngIf="!isOwnerSelected && this.relationship && this.relationship.following && !this.relationship.showing_reblogs">
|
||||
Unhide boosts from @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true" *ngIf="!isOwnerSelected"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="muteAccount()" *ngIf="!isOwnerSelected && this.relationship && !this.relationship.muting">
|
||||
Mute @{{ this.username }}
|
||||
</ng-template>
|
||||
|
@ -40,6 +46,14 @@
|
|||
<ng-template contextMenuItem (execute)="unblockAccount()" *ngIf="!isOwnerSelected && this.relationship && this.relationship.blocking">
|
||||
Unblock @{{ this.username }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true" *ngIf="!isOwnerSelected"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="blockDomain()" *ngIf="!isOwnerSelected && this.relationship && !this.relationship.domain_blocking">
|
||||
Block domain {{ this.domain }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem (execute)="unblockDomain()" *ngIf="!isOwnerSelected && this.relationship && this.relationship.domain_blocking">
|
||||
Unblock domain {{ this.domain }}
|
||||
</ng-template>
|
||||
<ng-template contextMenuItem divider="true" *ngIf="isOwnerSelected"></ng-template>
|
||||
<ng-template contextMenuItem (execute)="pinOnProfile()" *ngIf="statusWrapper && isOwnerSelected && !displayedStatus.pinned && displayedStatus.visibility === 'public'">
|
||||
Pin on profile
|
||||
</ng-template>
|
||||
|
|
|
@ -25,6 +25,7 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
|||
private loadedAccounts: AccountInfo[];
|
||||
displayedStatus: Status;
|
||||
username: string;
|
||||
domain: string;
|
||||
isOwnerSelected: boolean;
|
||||
|
||||
isEditingAvailable: boolean;
|
||||
|
@ -74,6 +75,7 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
this.username = account.acct.split('@')[0];
|
||||
this.domain = account.acct.split('@')[1];
|
||||
this.fullHandle = this.toolsService.getAccountFullHandle(account);
|
||||
}
|
||||
|
||||
|
@ -167,6 +169,38 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
|||
return false;
|
||||
}
|
||||
|
||||
hideBoosts(): boolean {
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
this.toolsService.findAccount(acc, this.fullHandle)
|
||||
.then(async (target: Account) => {
|
||||
const relationship = await this.mastodonService.hideBoosts(acc, target);
|
||||
this.relationship = relationship;
|
||||
this.relationshipChanged.next(relationship);
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err, acc);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unhideBoosts(): boolean {
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
this.toolsService.findAccount(acc, this.fullHandle)
|
||||
.then(async (target: Account) => {
|
||||
const relationship = await this.mastodonService.unhideBoosts(acc, target);
|
||||
this.relationship = relationship;
|
||||
this.relationshipChanged.next(relationship);
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err, acc);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
muteAccount(): boolean {
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
|
@ -241,6 +275,37 @@ export class StatusUserContextMenuComponent implements OnInit, OnDestroy {
|
|||
return false;
|
||||
}
|
||||
|
||||
blockDomain(): boolean {
|
||||
const response = confirm(`Are you really sure you want to block the entire ${this.domain} domain? You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.`);
|
||||
|
||||
if (response) {
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
this.mastodonService.blockDomain(acc, this.domain)
|
||||
.then(_ => {
|
||||
this.relationship.domain_blocking = true;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err, acc);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unblockDomain(): boolean {
|
||||
const acc = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
this.mastodonService.blockDomain(acc, this.domain)
|
||||
.then(_ => {
|
||||
this.relationship.domain_blocking = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.notificationService.notifyHttpError(err, acc);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
muteConversation(): boolean {
|
||||
const selectedAccount = this.toolsService.getSelectedAccounts()[0];
|
||||
|
||||
|
|
|
@ -281,6 +281,20 @@ export class MastodonWrapperService {
|
|||
});
|
||||
}
|
||||
|
||||
hideBoosts(currentlyUsedAccount: AccountInfo, account: Account): Promise<Relationship> {
|
||||
return this.refreshAccountIfNeeded(currentlyUsedAccount)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.hideBoosts(refreshedAccount, account);
|
||||
});
|
||||
}
|
||||
|
||||
unhideBoosts(currentlyUsedAccount: AccountInfo, account: Account): Promise<Relationship> {
|
||||
return this.refreshAccountIfNeeded(currentlyUsedAccount)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.unhideBoosts(refreshedAccount, account);
|
||||
});
|
||||
}
|
||||
|
||||
followHashtag(currentlyUsedAccount: AccountInfo, hashtag: string): Promise<Tag> {
|
||||
return this.refreshAccountIfNeeded(currentlyUsedAccount)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
|
@ -407,6 +421,20 @@ export class MastodonWrapperService {
|
|||
});
|
||||
}
|
||||
|
||||
blockDomain(account: AccountInfo, domain: string): Promise<void> {
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.blockDomain(refreshedAccount, domain);
|
||||
});
|
||||
}
|
||||
|
||||
unblockDomain(account: AccountInfo, domain: string): Promise<void> {
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
return this.mastodonService.unblockDomain(refreshedAccount, domain);
|
||||
});
|
||||
}
|
||||
|
||||
pinOnProfile(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
return this.refreshAccountIfNeeded(account)
|
||||
.then((refreshedAccount: AccountInfo) => {
|
||||
|
|
|
@ -357,6 +357,26 @@ export class MastodonService {
|
|||
|
||||
}
|
||||
|
||||
hideBoosts(currentlyUsedAccount: AccountInfo, account: Account): Promise<Relationship> {
|
||||
const route = `https://${currentlyUsedAccount.instance}${this.apiRoutes.follow}`.replace('{0}', account.id.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${currentlyUsedAccount.token.access_token}` });
|
||||
|
||||
let input = new FormData();
|
||||
input.append('reblogs', 'false');
|
||||
|
||||
return this.httpClient.post<Relationship>(route, input, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
unhideBoosts(currentlyUsedAccount: AccountInfo, account: Account): Promise<Relationship> {
|
||||
const route = `https://${currentlyUsedAccount.instance}${this.apiRoutes.follow}`.replace('{0}', account.id.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${currentlyUsedAccount.token.access_token}` });
|
||||
|
||||
let input = new FormData();
|
||||
input.append('reblogs', 'true');
|
||||
|
||||
return this.httpClient.post<Relationship>(route, input, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
followHashtag(currentlyUsedAccount: AccountInfo, hashtag: string): Promise<Tag> {
|
||||
const route = `https://${currentlyUsedAccount.instance}${this.apiRoutes.followHashtag}`.replace('{0}', hashtag);
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${currentlyUsedAccount.token.access_token}` });
|
||||
|
@ -524,6 +544,23 @@ export class MastodonService {
|
|||
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
blockDomain(account: AccountInfo, domain: string): Promise<void> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.blockDomain}`;
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
|
||||
let input = new FormData();
|
||||
input.append('domain', domain);
|
||||
|
||||
return this.httpClient.post<void>(route, input, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
unblockDomain(account: AccountInfo, domain: string): Promise<void> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.blockDomain}?domain=${domain}`;
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}`});
|
||||
|
||||
return this.httpClient.delete<void>(route, { headers: headers }).toPromise();
|
||||
}
|
||||
|
||||
pinOnProfile(account: AccountInfo, statusId: string): Promise<Status> {
|
||||
let route = `https://${account.instance}${this.apiRoutes.pinStatus}`.replace('{0}', statusId.toString());
|
||||
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
|
||||
|
|
|
@ -12,6 +12,7 @@ export class ApiRoutes {
|
|||
unfollow = '/api/v1/accounts/{0}/unfollow';
|
||||
block = '/api/v1/accounts/{0}/block';
|
||||
unblock = '/api/v1/accounts/{0}/unblock';
|
||||
blockDomain = '/api/v1/domain_blocks';
|
||||
mute = '/api/v1/accounts/{0}/mute';
|
||||
unmute = '/api/v1/accounts/{0}/unmute';
|
||||
muteStatus = '/api/v1/statuses/{0}/mute';
|
||||
|
|
Loading…
Reference in New Issue