Skip to content

Commit

Permalink
Chore: Change blacklist to blocklist (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Oct 16, 2023
1 parent da31890 commit 56373d0
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 113 deletions.
4 changes: 2 additions & 2 deletions src/app/action-log/pages/action-log/action-log.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ <h3 class="card-title">{{"app.filter.title" | transloco}}</h3>
<option *ngFor="let option of safelistedDomains" [value]="option">{{option}}</option>
</select>
</div>
<div class="form-group" *ngIf="safelistedDomains && blacklistedDomains">
<div class="form-group" *ngIf="safelistedDomains && blocklistedDomains">
<label for="inputTargetDomains">{{"app.target_domains" | transloco}}</label>
<select id="inputTargetDomains" formControlName="targetDomains" multiple tom-select [maxItems]="null" [create]="true">
<option *ngFor="let option of blacklistedDomains" [value]="option">{{option}}</option>
<option *ngFor="let option of blocklistedDomains" [value]="option">{{option}}</option>
<option *ngFor="let option of safelistedDomains" [value]="option">{{option}}</option>
</select>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/action-log/pages/action-log/action-log.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ActionLogComponent implements OnInit {
public lastPageReached: boolean = false;

public safelistedDomains: string[] | null = null;
public blacklistedDomains: string[] | null = null;
public blocklistedDomains: string[] | null = null;

public form = new FormGroup({
type: new FormControl<ActionLogReportType | null>(null),
Expand Down Expand Up @@ -78,7 +78,7 @@ export class ActionLogComponent implements OnInit {
)),
]).then(responses => {
this.safelistedDomains = responses[0];
this.blacklistedDomains = responses[1];
this.blocklistedDomains = responses[1];

this.filtersLoading = false;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export enum MastodonBlacklistSeverity {
export enum MastodonBlocklistSeverity {
Silence = "silence",
Suspend = "suspend",
RejectMedia = "noop",
Nothing = '',
}

export interface MastodonBlacklistItem {
export interface MastodonBlocklistItem {
id: string;
domain: string;
created_at: string;
severity: MastodonBlacklistSeverity;
severity: MastodonBlocklistSeverity;
reject_media: boolean;
reject_reports: boolean;
private_comment: string | null;
public_comment: string | null;
obfuscate: boolean;
}

export type MastodonBlacklistResponse = MastodonBlacklistItem[];
export type MastodonBlocklistResponse = MastodonBlocklistItem[];
6 changes: 3 additions & 3 deletions src/app/services/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {LemmySynchronizationSettings} from "../types/lemmy-synchronization-setti
import {CensureListFilters} from "../types/censure-list-filters";
import {SynchronizationMode} from "../types/synchronization-mode";
import {MastodonSynchronizationSettings} from "../types/mastodon-synchronization-settings";
import {MastodonBlacklistSeverity} from "../response/mastodon-blacklist.response";
import {MastodonBlocklistSeverity} from "../response/mastodon-blocklist.response";
import {BehaviorSubject, Observable} from "rxjs";

@Injectable({
Expand Down Expand Up @@ -123,8 +123,8 @@ export class DatabaseService {
ignoreInstanceList: [],
ignoreInstances: false,
reasonsPublic: false,
censuresMode: MastodonBlacklistSeverity.Suspend,
hesitationsMode: MastodonBlacklistSeverity.Silence,
censuresMode: MastodonBlocklistSeverity.Suspend,
hesitationsMode: MastodonBlocklistSeverity.Silence,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/services/lemmy-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class LemmyApiService {
);
}

public updateBlacklist(instance: string, jwt: string, newInstancesToBlock: string[]): Observable<void> {
public updateBlocklist(instance: string, jwt: string, newInstancesToBlock: string[]): Observable<void> {
const url = `https://${instance}/api/v3/site`;

return this.httpClient.put(url, {
Expand Down
24 changes: 12 additions & 12 deletions src/app/services/mastodon-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {Injectable} from '@angular/core';
import {EMPTY, expand, Observable, reduce} from "rxjs";
import {HttpClient} from "@angular/common/http";
import {AccessTokenResponse} from "../response/access-token.response";
import {MastodonBlacklistItem, MastodonBlacklistResponse} from "../response/mastodon-blacklist.response";
import {MastodonDomainBlacklistRequest} from "../types/mastodon-domain-blacklist-request";
import {MastodonBlocklistItem, MastodonBlocklistResponse} from "../response/mastodon-blocklist.response";
import {MastodonDomainBlocklistRequest} from "../types/mastodon-domain-blocklist-request";
import {MastodonLinkParserService} from "./mastodon-link-parser.service";

export interface GetTokenOptions {
Expand Down Expand Up @@ -37,10 +37,10 @@ export class MastodonApiService {
return this.httpClient.post<AccessTokenResponse>(url, formData);
}

public getBlacklist(instance: string, token: string): Observable<MastodonBlacklistResponse> {
public getBlocklist(instance: string, token: string): Observable<MastodonBlocklistResponse> {
const url = `https://${instance}/api/v1/admin/domain_blocks`;

return this.httpClient.get<MastodonBlacklistResponse>(url, {
return this.httpClient.get<MastodonBlocklistResponse>(url, {
headers: {
Authorization: `Bearer ${token}`,
},
Expand All @@ -53,7 +53,7 @@ export class MastodonApiService {
return EMPTY;
}

return this.httpClient.get<MastodonBlacklistResponse>(links.next, {
return this.httpClient.get<MastodonBlocklistResponse>(links.next, {
headers: {
Authorization: `Bearer ${token}`,
},
Expand All @@ -63,27 +63,27 @@ export class MastodonApiService {

return EMPTY;
}),
reduce((acc, value) => acc.concat(value.body!), <MastodonBlacklistResponse>[]),
reduce((acc, value) => acc.concat(value.body!), <MastodonBlocklistResponse>[]),
)
}

public blacklistInstance(
public addInstanceToBlocklist(
instance: string,
token: string,
instanceToBlacklist: string,
options: MastodonDomainBlacklistRequest = {}
): Observable<MastodonBlacklistItem> {
instanceToBlocklist: string,
options: MastodonDomainBlocklistRequest = {}
): Observable<MastodonBlocklistItem> {
const url = `https://${instance}/api/v1/admin/domain_blocks`;

return this.httpClient.post<MastodonBlacklistItem>(url, {...options, domain: instanceToBlacklist}, {
return this.httpClient.post<MastodonBlocklistItem>(url, {...options, domain: instanceToBlocklist}, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
}

public deleteBlacklist(instance: string, token: string, instanceId: string) {
public deleteFromBlocklist(instance: string, token: string, instanceId: string) {
const url = `https://${instance}/api/v1/admin/domain_blocks/${instanceId}`;
return this.httpClient.delete<{}>(url, {
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a routerLink="/instances/detail/{{instance}}">{{instance}}</a>
<app-tooltip *ngIf="!removed.includes(instance)" text="This instance is on both your Fediseer censure list and instance blocklist." />
<app-tooltip *ngIf="removed.includes(instance) && purgeMode" text="This instance is only on your instance blocklist but not on your Fediseer blocklist and will be removed from your instance's blocklist if you run synchronization." />
<app-tooltip *ngIf="removed.includes(instance) && !purgeMode" text="This instance is only on your instance blocklist but not on your Fediseer blocklist. It will not be removed because you don't have the 'Purge blacklist' option checked." />
<app-tooltip *ngIf="removed.includes(instance) && !purgeMode" text="This instance is only on your instance blocklist but not on your Fediseer blocklist. It will not be removed because you don't have the 'Purge blocklist' option checked." />
</td>
</tr>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export type OriginalToStringCallback<T> = ((instance: T) => string);
export type NewToStringCallback<T> = ((instance: T) => string);

@Component({
selector: 'app-blacklist-diff',
templateUrl: './blacklist-diff.component.html',
styleUrls: ['./blacklist-diff.component.scss']
selector: 'app-blocklist-diff',
templateUrl: './blocklist-diff.component.html',
styleUrls: ['./blocklist-diff.component.scss']
})
export class BlacklistDiffComponent<TOriginalInstance, TNewInstance> implements OnInit, OnChanges {
export class BlocklistDiffComponent<TOriginalInstance, TNewInstance> implements OnInit, OnChanges {

@Input() originalList: TOriginalInstance[] = [];
@Input() newList: TNewInstance[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
In addition to instances you have censured, all instances censured by instances you have endorsed will be blocked as well.
</small>
<small *ngIf="form.controls.mode.value === SynchronizationMode.CustomInstances">
Only blacklist by your instance and the instances you specify manually will be blocked.
Only blocklist by your instance and the instances you specify manually will be blocked.
</small>
</div>
<div class="form-group position-relative" *ngIf="form.controls.mode.value === SynchronizationMode.CustomInstances">
Expand All @@ -25,20 +25,20 @@
</div>
<div class="form-group">
<div class="custom-control custom-switch custom-switch-on-danger">
<input class="custom-control-input" type="checkbox" id="inputPurge" formControlName="purgeBlacklist" aria-describedby="inputPurgeDescription" />
<label for="inputPurge" class="custom-control-label">Purge blacklist</label>
<input class="custom-control-input" type="checkbox" id="inputPurge" formControlName="purgeBlocklist" aria-describedby="inputPurgeDescription" />
<label for="inputPurge" class="custom-control-label">Purge blocklist</label>
</div>
<small id="inputPurgeDescription">If enabled, your blacklist will be purged before synchronizing the new one. Make sure you've backed up the original one.</small>
<small id="inputPurgeDescription">If enabled, your blocklist will be purged before synchronizing the new one. Make sure you've backed up the original one.</small>
</div>
<div class="form-group">
<div class="custom-control custom-switch custom-switch-on-danger">
<input class="custom-control-input" type="checkbox" id="inputFilterReasons" formControlName="filterByReasons" aria-describedby="inputFilterReasonsDescription" />
<label for="inputFilterReasons" class="custom-control-label">Filter by reasons</label>
</div>
<small id="inputFilterReasonsDescription">
If enabled, only instances with censure reasons you specify will get blacklisted.
If enabled, only instances with censure reasons you specify will get blocklisted.
<br>
<strong>Note that your own blacklist is always synchronized in full and this setting is ignored for instances that <em>{{myInstance}}</em> itself censured.</strong>
<strong>Note that your own blocklist is always synchronized in full and this setting is ignored for instances that <em>{{myInstance}}</em> itself censured.</strong>
</small>
</div>
<div class="form-group position-relative" *ngIf="form.controls.filterByReasons.value">
Expand All @@ -52,14 +52,14 @@
<div class="form-group">
<div class="custom-control custom-switch custom-switch-on-danger">
<input class="custom-control-input" type="checkbox" id="inputIgnoreInstances" formControlName="ignoreInstances" aria-describedby="inputIgnoreInstancesDescription" />
<label for="inputIgnoreInstances" class="custom-control-label">Exclude instances from blacklist</label>
<label for="inputIgnoreInstances" class="custom-control-label">Exclude instances from blocklist</label>
</div>
<small id="inputIgnoreInstancesDescription">
If enabled, you can specify a list of instances that will be excluded from blacklisting even if they match the other rules.
If enabled, you can specify a list of instances that will be excluded from blocking even if they match the other rules.
<br>
<strong>Note that instances you endorse are always excluded from blacklisting.</strong>
<strong>Note that instances you endorse are always excluded from blocking.</strong>
<br>
<strong>Note that your own blacklist is always synchronized in full and this setting is ignored for instances that <em>{{myInstance}}</em> itself censured.</strong>
<strong>Note that your own blocklist is always synchronized in full and this setting is ignored for instances that <em>{{myInstance}}</em> itself censured.</strong>
</small>
</div>
<div class="form-group position-relative" *ngIf="form.controls.ignoreInstances.value">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
public myInstance: string = this.authManager.currentInstanceSnapshot.name;

public form = new FormGroup({
purgeBlacklist: new FormControl<boolean>(false, [Validators.required]),
purgeBlocklist: new FormControl<boolean>(false, [Validators.required]),
mode: new FormControl<SynchronizationMode>(SynchronizationMode.Own, [Validators.required]),
customInstances: new FormControl<string[]>([]),
filterByReasons: new FormControl<boolean>(false),
Expand Down Expand Up @@ -123,7 +123,7 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
const settings = this.getSettingsCallback(this.database);
this.form.patchValue({
mode: settings.mode,
purgeBlacklist: settings.purge,
purgeBlocklist: settings.purge,
filterByReasons: settings.filterByReasons,
includeHesitations: settings.includeHesitations,
ignoreInstanceList: settings.ignoreInstanceList,
Expand All @@ -140,7 +140,7 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
settings.reasonsFilter = changes.reasonsFilter ?? [];
settings.mode = changes.mode ?? SynchronizationMode.Own;
settings.filterByReasons = changes.filterByReasons ?? false;
settings.purge = changes.purgeBlacklist ?? false;
settings.purge = changes.purgeBlocklist ?? false;
settings.customInstances = changes.customInstances ?? [];
settings.ignoreInstances = changes.ignoreInstances ?? false;
settings.ignoreInstanceList = changes.ignoreInstanceList ?? [];
Expand Down Expand Up @@ -168,7 +168,7 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
this.loadCustomInstancesSelect(mode);
this._modeChanged.next(mode);
});
this.form.controls.purgeBlacklist.valueChanges.subscribe(purge => {
this.form.controls.purgeBlocklist.valueChanges.subscribe(purge => {
if (purge === null) {
return;
}
Expand All @@ -187,8 +187,8 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
this.loadCustomInstancesSelect(this.form.controls.mode.value);
this._modeChanged.next(this.form.controls.mode.value);
}
if (this.form.controls.purgeBlacklist.value !== null) {
this._purgeChanged.next(this.form.controls.purgeBlacklist.value);
if (this.form.controls.purgeBlocklist.value !== null) {
this._purgeChanged.next(this.form.controls.purgeBlocklist.value);
}
if (this.form.controls.filterByReasons.value) {
this.loadReasons();
Expand Down Expand Up @@ -289,9 +289,9 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
throw new Error(`Unsupported mode: ${mode}`);
}

let foreignInstanceBlacklist: InstanceDetailResponse[] = [];
let foreignInstanceBlocklist: InstanceDetailResponse[] = [];
if (sourceFrom.length) {
foreignInstanceBlacklist = await (async () => {
foreignInstanceBlocklist = await (async () => {
const censures = hesitationsMode === true ? [] : await this.getCensuresByInstances(sourceFrom);
const hesitations = hesitationsMode === false || (hesitationsMode === null && !this.form.controls.includeHesitations.value)
? []
Expand All @@ -305,21 +305,21 @@ export class FilterFormComponent<TSettings extends SynchronizationSettings> impl
})();
if (this.form.controls.filterByReasons.value && this.form.controls.reasonsFilter.value) {
const reasons = this.form.controls.reasonsFilter.value!;
foreignInstanceBlacklist = foreignInstanceBlacklist.filter(
foreignInstanceBlocklist = foreignInstanceBlocklist.filter(
instance => NormalizedInstanceDetailResponse.fromInstanceDetail(instance).unmergedCensureReasons.filter(
reason => reasons.includes(reason),
).length,
);
}
if (this.form.controls.ignoreInstances.valid && this.form.controls.ignoreInstanceList.value) {
foreignInstanceBlacklist = foreignInstanceBlacklist.filter(
foreignInstanceBlocklist = foreignInstanceBlocklist.filter(
instance => !this.form.controls.ignoreInstanceList.value!.includes(instance.domain),
);
}
}

const myEndorsed = this.cache[`endorsed:${myInstance}`]!.map(instance => instance.domain);
const result = [...this.cache[myInstanceCacheKey]!, ...foreignInstanceBlacklist];
const result = [...this.cache[myInstanceCacheKey]!, ...foreignInstanceBlocklist];
const handled: string[] = [];

return result.filter(instance => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h3>Preview</h3>
</div>

<ng-template #previewTable>
<app-blacklist-diff
<app-blocklist-diff
[originalList]="sourceBlockedInstances"
[newList]="instancesToBanPreview!"
[purgeMode]="purgeMode ?? false"
Expand Down Expand Up @@ -108,7 +108,7 @@ <h3>Preview</h3>
</div>

<ng-template #previewLemmyToFediseer>
<app-blacklist-diff
<app-blocklist-diff
[originalList]="myCensuredInstances"
[newList]="sourceBlockedInstances"
[newToStringCallback]="lemmyToFediseerSyncNewListCallback"
Expand All @@ -124,13 +124,13 @@ <h3>Preview</h3>

<div class="card">
<div class="card-header">
<h3 class="card-title">Original blacklist</h3>
<h3 class="card-title">Original blocklist</h3>
</div>
<div class="card-body">
<p>
Please back up this list before attempting any synchronization.
<strong>
If you move away from this page after a failed operation, there's no way to retrieve the original blacklist.
If you move away from this page after a failed operation, there's no way to retrieve the original blocklist.
</strong>
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SaveSettingsCallback
} from "../../components/filter-form/filter-form.component";
import {LemmySynchronizationSettings} from "../../../types/lemmy-synchronization-settings";
import {NewToStringCallback} from "../../components/blacklist-diff/blacklist-diff.component";
import {NewToStringCallback} from "../../components/blocklist-diff/blocklist-diff.component";
import {SuccessResponse} from "../../../response/success.response";
import {CachedFediseerApiService} from "../../../services/cached-fediseer-api.service";

Expand Down Expand Up @@ -68,7 +68,7 @@ export class SynchronizeLemmyComponent implements OnInit {
}

public async ngOnInit(): Promise<void> {
this.titleService.title = 'Blacklist synchronization - Lemmy';
this.titleService.title = 'Blocklist synchronization - Lemmy';

const settings = this.database.lemmySynchronizationSettings;
this.form.patchValue({
Expand Down Expand Up @@ -201,7 +201,7 @@ export class SynchronizeLemmyComponent implements OnInit {
;

try {
await toPromise(this.lemmyApi.updateBlacklist(myInstance, jwt, newInstances));
await toPromise(this.lemmyApi.updateBlocklist(myInstance, jwt, newInstances));
} catch (e) {
const error = (<HttpErrorResponse>e).error.error;
this.messageService.createError(`There was an error: ${error}`);
Expand Down
Loading

0 comments on commit 56373d0

Please sign in to comment.