1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00
Files
browser/apps/cli/src/tools/send/commands/remove-password.command.ts
Oscar Hinton e767295c86 [PM-5979] Refactor EnvironmentService (#8040)
Refactor environment service to emit a single observable. This required significant changes to how the environment service behaves and tackles much of the tech debt planned for it.
2024-03-21 09:09:44 -07:00

32 lines
1.1 KiB
TypeScript

import { firstValueFrom } from "rxjs";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { SendService } from "@bitwarden/common/tools/send/services//send.service.abstraction";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { Response } from "../../../models/response";
import { SendResponse } from "../models/send.response";
export class SendRemovePasswordCommand {
constructor(
private sendService: SendService,
private sendApiService: SendApiService,
private environmentService: EnvironmentService,
) {}
async run(id: string) {
try {
await this.sendApiService.removePassword(id);
const updatedSend = await this.sendService.get(id);
const decSend = await updatedSend.decrypt();
const env = await firstValueFrom(this.environmentService.environment$);
const webVaultUrl = env.getWebVaultUrl();
const res = new SendResponse(decSend, webVaultUrl);
return Response.success(res);
} catch (e) {
return Response.error(e);
}
}
}