Skip to content

Commit

Permalink
add option to disable preview of links in messages sent
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Jun 22, 2024
1 parent 390fe58 commit 7428133
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ This configuration file holds general application settings. Default content:
cache_enabled=1
coredump_enabled=0
downloads_dir=
link_send_preview=1
proxy_host=
proxy_pass=
proxy_port=
Expand Down Expand Up @@ -295,6 +296,10 @@ Specifies whether to enable core dumps on application crash.
Specifies a custom downloads directory path to save attachments to. If not
specified, the default dir is `~/Downloads` if exists, otherwise `~`.

### link_send_preview

Specifies whether to enable preview for links in messages sent (Telegram only).

### proxy_

SOCKS5 proxy server details. To enable proxy usage the parameters `host` and
Expand Down
2 changes: 1 addition & 1 deletion lib/common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

#pragma once

#define NCHAT_VERSION "4.92"
#define NCHAT_VERSION "4.93"
3 changes: 2 additions & 1 deletion lib/ncutil/src/appconfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// appconfig.cpp
//
// Copyright (c) 2021-2023 Kristofer Berggren
// Copyright (c) 2021-2024 Kristofer Berggren
// All rights reserved.
//
// nchat is distributed under the MIT license, see LICENSE for details.
Expand All @@ -23,6 +23,7 @@ void AppConfig::Init()
{ "cache_enabled", "1" },
{ "coredump_enabled", "0" },
{ "downloads_dir", "" },
{ "link_send_preview", "1" },
{ "proxy_host", "" },
{ "proxy_pass", "" },
{ "proxy_port", "" },
Expand Down
6 changes: 6 additions & 0 deletions lib/tgchat/src/tgchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,12 @@ td::td_api::object_ptr<td::td_api::formattedText> TgChat::Impl::GetFormattedText
td::td_api::object_ptr<td::td_api::inputMessageText> TgChat::Impl::GetMessageText(const std::string& p_Text)
{
auto message_content = td::td_api::make_object<td::td_api::inputMessageText>();

static const bool linkSendPreview = AppConfig::GetBool("link_send_preview");
auto link_preview_options = td::td_api::make_object<td::td_api::linkPreviewOptions>();
link_preview_options->is_disabled_ = !linkSendPreview;
message_content->link_preview_options_ = std::move(link_preview_options);

message_content->text_ = GetFormattedText(p_Text);
return message_content;
}
Expand Down
2 changes: 1 addition & 1 deletion src/nchat.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH NCHAT "1" "June 2024" "nchat v4.92" "User Commands"
.TH NCHAT "1" "June 2024" "nchat v4.93" "User Commands"
.SH NAME
nchat \- ncurses chat
.SH SYNOPSIS
Expand Down

0 comments on commit 7428133

Please sign in to comment.