-
Notifications
You must be signed in to change notification settings - Fork 49
Add support for telegram chat links opening #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
948e45f
33931b7
25e0fcd
ea450ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [D-BUS Service] | ||
| Name=@application_id@ | ||
| Exec=@bindir@/telegrand --gapplication-service |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,3 +74,15 @@ if glib_compile_schemas.found() | |
| ], | ||
| ) | ||
| endif | ||
|
|
||
| # D-bus service | ||
krlade marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| service_conf = configuration_data() | ||
| service_conf.set('application_id', application_id) | ||
| service_conf.set('bindir', bindir) | ||
| configure_file( | ||
| input: '@[email protected]'.format(base_id), | ||
| output: '@[email protected]'.format(application_id), | ||
| configuration: service_conf, | ||
| install: true, | ||
| install_dir: datadir / 'dbus-1' / 'services', | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -729,6 +729,37 @@ impl SessionManager { | |
| } | ||
| } | ||
|
|
||
| pub(crate) fn handle_telegram_link(&self, link: String) { | ||
| let client_id = self.active_logged_in_client_id(); | ||
| if let Some(client_id) = client_id { | ||
| spawn(clone!(@weak self as obj => async move { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of having all these spawn calls, I think it's better to have this whole function (and |
||
| let result = functions::get_internal_link_type(link, client_id).await; | ||
| if let Ok(link_type) = result { | ||
| use enums::InternalLinkType::*; | ||
| // TODO: Support other link types | ||
| #[allow(clippy::single_match)] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to do that, just follow what clippy says. I know that we'll need a match arm in the future, but I prefer not ignore clippy :) |
||
| match link_type { | ||
| PublicChat(data) => obj.open_chat_by_username(data.chat_username), | ||
| _ => (), | ||
| } | ||
| } | ||
| })); | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn open_chat_by_username(&self, username: String) { | ||
| let client_id = self.active_logged_in_client_id(); | ||
| if let Some(client_id) = client_id { | ||
| spawn(clone!(@weak self as obj => async move { | ||
| let result = functions::search_public_chat(username, client_id).await; | ||
| if let Ok(chat) = result { | ||
| let enums::Chat::Chat(chat) = chat; | ||
| obj.select_chat(client_id, chat.id); | ||
| } | ||
| })) | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn begin_chats_search(&self) { | ||
| if let Some(client_id) = self.active_logged_in_client_id() { | ||
| let clients = self.imp().clients.borrow(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.