Message Requests: Add new "Report spam and block" button
This commit is contained in:
parent
20e501d9f1
commit
d4dc9b8e39
33 changed files with 630 additions and 92 deletions
|
@ -12,6 +12,8 @@ import { MessageModel } from '../models/messages';
|
|||
import { MessageType } from '../state/ducks/conversations';
|
||||
import { assert } from '../util/assert';
|
||||
import { maybeParseUrl } from '../util/url';
|
||||
import { addReportSpamJob } from '../jobs/helpers/addReportSpamJob';
|
||||
import { reportSpamJobQueue } from '../jobs/reportSpamJobQueue';
|
||||
|
||||
type GetLinkPreviewImageResult = {
|
||||
data: ArrayBuffer;
|
||||
|
@ -317,6 +319,11 @@ Whisper.AlreadyRequestedToJoinToast = Whisper.ToastView.extend({
|
|||
template: () => window.i18n('GroupV2--join--already-awaiting-approval'),
|
||||
});
|
||||
|
||||
const ReportedSpamAndBlockedToast = Whisper.ToastView.extend({
|
||||
template: () =>
|
||||
window.i18n('MessageRequests--block-and-report-spam-success-toast'),
|
||||
});
|
||||
|
||||
Whisper.ConversationLoadingScreen = Whisper.View.extend({
|
||||
template: () => $('#conversation-loading-screen').html(),
|
||||
className: 'conversation-loading-screen',
|
||||
|
@ -638,11 +645,8 @@ Whisper.ConversationView = Whisper.View.extend({
|
|||
onDelete: () => {
|
||||
this.syncMessageRequestResponse('onDelete', messageRequestEnum.DELETE);
|
||||
},
|
||||
onBlockAndDelete: () => {
|
||||
this.syncMessageRequestResponse(
|
||||
'onBlockAndDelete',
|
||||
messageRequestEnum.BLOCK_AND_DELETE
|
||||
);
|
||||
onBlockAndReportSpam: () => {
|
||||
this.blockAndReportSpam();
|
||||
},
|
||||
onStartGroupMigration: () => this.startMigrationToGV2(),
|
||||
onCancelJoinRequest: async () => {
|
||||
|
@ -963,11 +967,8 @@ Whisper.ConversationView = Whisper.View.extend({
|
|||
onBlock: () => {
|
||||
this.syncMessageRequestResponse('onBlock', messageRequestEnum.BLOCK);
|
||||
},
|
||||
onBlockAndDelete: () => {
|
||||
this.syncMessageRequestResponse(
|
||||
'onBlockAndDelete',
|
||||
messageRequestEnum.BLOCK_AND_DELETE
|
||||
);
|
||||
onBlockAndReportSpam: () => {
|
||||
this.blockAndReportSpam();
|
||||
},
|
||||
onDelete: () => {
|
||||
this.syncMessageRequestResponse(
|
||||
|
@ -1462,6 +1463,28 @@ Whisper.ConversationView = Whisper.View.extend({
|
|||
});
|
||||
},
|
||||
|
||||
blockAndReportSpam(): Promise<void> {
|
||||
const messageRequestEnum =
|
||||
window.textsecure.protobuf.SyncMessage.MessageRequestResponse.Type;
|
||||
const { model }: { model: ConversationModel } = this;
|
||||
|
||||
return this.longRunningTaskWrapper({
|
||||
name: 'blockAndReportSpam',
|
||||
task: async () => {
|
||||
await Promise.all([
|
||||
model.syncMessageRequestResponse(messageRequestEnum.BLOCK),
|
||||
addReportSpamJob({
|
||||
conversation: model.format(),
|
||||
getMessageServerGuidsForSpam:
|
||||
window.Signal.Data.getMessageServerGuidsForSpam,
|
||||
jobQueue: reportSpamJobQueue,
|
||||
}),
|
||||
]);
|
||||
this.showToast(ReportedSpamAndBlockedToast);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
getPropsForAttachmentList() {
|
||||
const draftAttachments = this.model.get('draftAttachments') || [];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue