roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.79k stars 1.62k forks source link

newmail_notifier does not revert to correct favicon (+ feature request to customize the favicon) #9575

Open CombeeMike opened 1 month ago

CombeeMike commented 1 month ago

Prerequisites

Describe the issue

I have my own skin which provides a custom favicon using the following section in its meta.json:

{
  // ...
  "links": {
    "icon": [
      { "type": "image/png", "sizes": "16x16", "href": "/images/favicon.svg" },
      { "type": "image/png", "sizes": "32x23", "href": "/images/favicon.svg" }
    ]
  }
  // ...
}

Bug

When a new mail arrives, the notifier plugin removes this favicon and shows its own "new mail" favicon from /plugins/newmail_notifier/favicon.ico which is what it should do.

However, when marking all unread emails as read, the default icon from /skins/elastic/images/favicon.ico is loaded instead of the one from my skin.

In the source code of the plugin I've seen that it loads the default icon from rcmail.env.favicon_href but I don't see where this gets its value from. Is there some kind of config which I can adjust to set it to the correct favicon from my skin?

Feature request

Besides that bug, I'd love to see some setting which allows me to tell the plugin which icon to show when new messages arrive instead of the default /plugins/newmail_notifier/favicon.ico.

Workaround

For the time being, I managed to set some hard redirects in my apache site config which solve both, the bug and the feature request:

<VirtualHost _default_:443>

  // ...

  Redirect permanent /plugins/newmail_notifier/favicon.ico /skins/my-skin/images/favicon_new_mail.svg
  Redirect permanent /skins/elastic/images/favicon.ico /skins/my-skin/images/favicon.svg

  // ...

</VirtualHost>

What browser(s) are you seeing the problem on?

Firefox

What version of PHP are you using?

8.1.2

What version of Roundcube are you using?

1.6.8

JavaScript errors

No response

PHP errors

No response

alecpl commented 1 month ago

rcmail.env.favicon_href is being set in newmail_notifier.js. I see that with skin configuration like above there's a problem:

  1. The code looks for link[rel="shortcut icon"] elements, but your icons will have rel="icon" attribute.
  2. The code does not work properly with multiple link elements anyway.

You can probably workaround the first issue by using "shortcut icon" instead of "icon" in your skin config.