From 4cf1f080bf113d6e30383eb1fddd37ce16025558 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 10 Jun 2020 22:47:06 -0400 Subject: [PATCH] Adding delete picture via pict-rs delete tokens. Fixes #505 --- docker/dev/docker-compose.yml | 2 +- server/src/api/post.rs | 12 ++++----- ui/src/components/comment-form.tsx | 43 +++++++++++++++++++++--------- ui/src/components/post-form.tsx | 8 ++++++ ui/src/utils.ts | 23 ++++++++++++++++ ui/translations/en.json | 2 ++ 6 files changed, 70 insertions(+), 20 deletions(-) diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 60b04beb..ab9ab7d8 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -28,7 +28,7 @@ services: restart: always pictrs: - image: asonix/pictrs:v0.1.0-r13 + image: asonix/pictrs:v0.1.3-r1 ports: - "127.0.0.1:8537:8080" user: 991:991 diff --git a/server/src/api/post.rs b/server/src/api/post.rs index 0e8a17e7..9eeb5158 100644 --- a/server/src/api/post.rs +++ b/server/src/api/post.rs @@ -116,8 +116,8 @@ impl Perform for Oper { return Err(APIError::err("site_ban").into()); } - // Fetch Iframely and Pictshare cached image - let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) = + // Fetch Iframely and pictrs cached image + let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) = fetch_iframely_and_pictrs_data(data.url.to_owned()); let post_form = PostForm { @@ -135,7 +135,7 @@ impl Perform for Oper { embed_title: iframely_title, embed_description: iframely_description, embed_html: iframely_html, - thumbnail_url: pictshare_thumbnail, + thumbnail_url: pictrs_thumbnail, }; let inserted_post = match Post::create(&conn, &post_form) { @@ -450,8 +450,8 @@ impl Perform for Oper { return Err(APIError::err("site_ban").into()); } - // Fetch Iframely and Pictshare cached image - let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) = + // Fetch Iframely and Pictrs cached image + let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) = fetch_iframely_and_pictrs_data(data.url.to_owned()); let post_form = PostForm { @@ -469,7 +469,7 @@ impl Perform for Oper { embed_title: iframely_title, embed_description: iframely_description, embed_html: iframely_html, - thumbnail_url: pictshare_thumbnail, + thumbnail_url: pictrs_thumbnail, }; let _updated_post = match Post::update(&conn, data.edit_id, &post_form) { diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 7abab752..79aa91bd 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -18,6 +18,7 @@ import { setupTribute, wsJsonToRes, emojiPicker, + pictrsDeleteToast, } from '../utils'; import { WebSocketService, UserService } from '../services'; import autosize from 'autosize'; @@ -162,8 +163,9 @@ export class CommentForm extends Component { {this.state.commentForm.content && (