Skip to content

Disable message notifications from active chatrooms#2021

Closed
Bionicgitman wants to merge 34 commits intoprofanity-im:masterfrom
Bionicgitman:feat/1987-DisableSelWinNotifs
Closed

Disable message notifications from active chatrooms#2021
Bionicgitman wants to merge 34 commits intoprofanity-im:masterfrom
Bionicgitman:feat/1987-DisableSelWinNotifs

Conversation

@Bionicgitman
Copy link
Copy Markdown

@Bionicgitman Bionicgitman commented Mar 5, 2025

Currently Profanity sends notifications even if you are focused on the same chat window as the recipient message.
It should account for whenever profanity is the focused window or not.
See #1987 .

@Bionicgitman Bionicgitman changed the title feat/1987-DisableSelWinNotifs Disable message notifications from active chatrooms Mar 5, 2025
@Bionicgitman Bionicgitman marked this pull request as draft March 5, 2025 13:37
Copy link
Copy Markdown
Member

@jubalh jubalh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jubalh
Copy link
Copy Markdown
Member

jubalh commented Mar 6, 2025

Thanks for this PR!
Any reason its just a draft yet?

@Bionicgitman
Copy link
Copy Markdown
Author

I have yet to include the AFK portion, I will submit it soon

@Bionicgitman Bionicgitman marked this pull request as ready for review March 6, 2025 11:40
@sjaeckel sjaeckel force-pushed the feat/1987-DisableSelWinNotifs branch from 3e1e63c to 6f1f43e Compare March 13, 2025 08:59
Copy link
Copy Markdown
Member

@sjaeckel sjaeckel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had a look at the existing implementation and found that we already have PREF_NOTIFY_ROOM_CURRENT resp. PREF_NOTIFY_CHAT_CURRENT. Did you try enabling those before making these changes?

The main difference is then the check for the idle time, which should happen inside prefs_do_room_notify() resp. prefs_do_chat_notify() and the time should maybe be configurable? (CC @jubalh) The ChatState is only for 1on1 chats, so we can't use that.

@jubalh
Copy link
Copy Markdown
Member

jubalh commented Mar 25, 2025

the time should maybe be configurable

Makes sense :)

@sjaeckel sjaeckel requested a review from jubalh April 16, 2025 10:10
Copy link
Copy Markdown

@Privat33r-dev Privat33r-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. In general, as it was mentioned earlier, disabling notification for the current chat room is already enabled in a form of a preference, condition for which is being checked inside of the prefs_do_chat_notify, called to calculate notify variable.

if ((current_win == FALSE) || ((current_win == TRUE) && prefs_get_boolean(PREF_NOTIFY_CHAT_CURRENT))) {

I suggest to instead make changes in the prefs_do_chat_notify and prefs_do_room_notify, using configurable preference for idling, as it was suggested earlier by @sjaeckel.

Comment thread src/event/server_events.c Outdated
mucwin->last_msg_timestamp = g_date_time_new_now_local();

if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message->from_jid->resourcepart, message->plain, mention, triggers != NULL)) {
if ((prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message->from_jid->resourcepart, message->plain, mention, triggers != NULL) && !wins_is_current(window)) || ui_get_idle_time() > 1000) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with conditions as explained in another comment.

Comment thread src/ui/chatwin.c Outdated
@jubalh
Copy link
Copy Markdown
Member

jubalh commented Aug 22, 2025

@Bionicgitman ping

Bionicgitman and others added 2 commits August 25, 2025 08:46
@Privat33r-dev
Copy link
Copy Markdown

Unfortunately, it still duplicates functionality of PREF_NOTIFY_CHAT_CURRENT.

@Bionicgitman
Copy link
Copy Markdown
Author

Started working on adding idle time as an option. Tell me if there are any problems with it or if it isn't complete.

@jubalh
Copy link
Copy Markdown
Member

jubalh commented Dec 3, 2025

Well, what's strange for sure is that there are a couple of merge commits. Maybe get rid of them so the tree is clean. And in the future just rebase.

@Bionicgitman Bionicgitman deleted the feat/1987-DisableSelWinNotifs branch December 6, 2025 04:16
@Bionicgitman Bionicgitman restored the feat/1987-DisableSelWinNotifs branch December 6, 2025 04:16
@Bionicgitman Bionicgitman reopened this Dec 6, 2025
@jubalh
Copy link
Copy Markdown
Member

jubalh commented Mar 28, 2026

Is it possible to clean up the commit history?

Several users have reported segfaults when starting up profanity which
has OMEMO support, but OMEMO is not set up yet.

@StefanKropp has been able to reproduce this and tracked it down to
`_load_identity()` calling `omemo_known_devices_keyfile_save()`.
The latter then calls `save_keyfile()` which calls
`g_key_file_save_to_file()`. This can then fail if one of the first two
strings is NULL and won't set the `error` on return. In its error handling
`save_keyfile()` unconditionally dereferences `error` which leads to the
segfault.

Fix this and also go through the entire codebase and verify that the usage
of `GError` is done correctly.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
sjaeckel and others added 24 commits March 28, 2026 09:48
So one can easily see if there are two instances running, if they are
logging to the same file.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
When setting up OMEMO for the first time via `/omemo gen` one had
to reconnect in order to make OMEMO work. This is fixed now.

Fixes: 5b6b513 ("Fix OMEMO keyfile loading")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
With that command one can see the modifications of the runtime
configuration vs. the saved configuration.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
First let's make clear we're currently using SHA1 & untangle the tlscerts
API from fingerprint specific details.

Related-to: #2068
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This also reads the certificate SHA256 and pubkey fingerprint from
libstrophe, but doesn't store it persistently yet.

Related-to: #2068
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
If a cert has a SHA256 use that one and only use SHA1 as fallback.

Closes: #2068
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
... as much as possible ... subject and issuer details excluded.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* add can simply do a `memcpy()`.
* in remove we don't have to put the array in a list in order to put it
  back into an array again. Also we don't have to `strdup()` each entry,
  which leads to even less allocations.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* use `gchar` instead of `char`.
* improve situations when strings must be duplicated or can pass ownership.
* encapsulate the X.509 name details into a struct.
* prevent memory leaks if a name detail is contained multiple times.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* Add new TLS policy `direct` as a replacement for `legacy`.
* Document that `/[command]?` prints the help of a command.
* Add option to get help via `/command help`.
* Fix `my-prof.supp` generation and tests for out-of-source builds.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* Less `GString`.
* Don't `g_free()` a `strdup()`'ed string.
* Don't lookup the `console` window X times, but only once.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
If one is running multiple instances of profanity, the behavior of the
accounts module was to constantly overwrite the accounts file with the
version that was on-disk of the first instance of profanity started.

This is changed now in order to only write what we modified, we keep a
copy of the accounts file and when "saving" we re-read accounts from disk
and only update the values of the modified account.

This is not 100% fool proof if one modifies the same account from two
different instances, but still better than before.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* No need to call `g_key_file_has_key()` before calling a getter.
* Add helper to convert `gcharv` to `glist`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
No need to have a fixed list of keys, we can simply copy all existing ones.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
e.g. if one connects with an account for the first time and the server
returns a `see-other-host` error.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Related-to: #2078
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Add /opt/homebrew/{include,lib} flags for apple silicon macs, which are not included as default search paths by Clang/GCC. (Homebrew uses /usr/local/{include,lib} on intel macs)
On macOS running ./configure --enable-omemo was failing to find gcrypt despite being installed.
@Bionicgitman Bionicgitman force-pushed the feat/1987-DisableSelWinNotifs branch from 653ccfd to 4fd2c4c Compare March 28, 2026 06:49
@jubalh
Copy link
Copy Markdown
Member

jubalh commented Apr 2, 2026

The commit history is even more of a mess now :)

@jubalh
Copy link
Copy Markdown
Member

jubalh commented Apr 3, 2026

I just had a look at the existing implementation and found that we already have PREF_NOTIFY_ROOM_CURRENT resp. PREF_NOTIFY_CHAT_CURRENT. Did you try enabling those before making these changes?

Closing this for this reason and due to polluted history.

@jubalh jubalh closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants