leits / MeetingBar

🇺🇦 Your meetings at your fingertips in the macOS menu bar
https://meetingbar.app
Apache License 2.0
4.51k stars 199 forks source link

Incorrect Microsoft Teams Link Detection in MeetingBar #755

Open acamposhd opened 2 months ago

acamposhd commented 2 months ago

Summary:

MeetingBar is selecting the incorrect Microsoft Teams link by default. The application should prioritize the link that opens directly to the meeting rather than the one that only opens the Teams app.

Steps to Reproduce:

Schedule a job event with two Microsoft Teams links. Ensure one link opens directly to the meeting (https://teams.microsoft.com/l/meetup-join/...) and the other link opens the Teams app. Add the event to MeetingBar.

Expected Behavior:

MeetingBar should identify and open the link that takes you directly to the meeting, represented by the URL pattern:

https://teams.microsoft.com/l/meetup-join/19%3ameeting_[^\/]+/0\?context=%7b%22Tid%22%3a[^&]+%7d

The correct link should also display the Teams icon.

Actual Behavior:

MeetingBar defaults to the link that opens just the Teams app, resulting in the user having to manually navigate to the meeting. Furthermore, when using the regex workaround, the Teams icon does not display as expected.

Notes:

The regex provided successfully identifies the correct meeting link, but it doesn't render the Teams icon as expected.

dosubot[bot] commented 2 months ago

Hey there, @acamposhd! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this issue together!

To address the issue of MeetingBar selecting the incorrect Microsoft Teams link, you need to ensure that the application prioritizes the link that opens directly to the meeting. Here's how you can configure MeetingBar to achieve this:

  1. Set the Default Browser for Teams Links: Ensure that the TeamsAppBrowser is not set as the default browser for Teams meetings. Instead, set a standard web browser as the default. This can be done by changing the Defaults[.teamsBrowser] setting to a web browser other than TeamsAppBrowser.

    Defaults[.teamsBrowser] = .defaultBrowser // or any other web browser you prefer
  2. Modify the Link Detection Logic: MeetingBar parses and stores multiple links from a single calendar event by checking several fields: location, url, notes, and notes with HTML tags stripped. The first detected meeting link is stored in the meetingLink property. Ensure that the regex pattern for the direct meeting link is prioritized.

    let linkFields = [
       location,
       url?.absoluteString,
       notes,
       notes?.htmlTagsStripped()
    ].compactMap { $0 }
    
    for linkField in linkFields {
       if var detectedLink = detectMeetingLink(linkField) {
           if detectedLink.service == .meet,
              let account = calendar.email,
              let urlEncodedAccount = account.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
               detectedLink.url = URL(string: (detectedLink.url.absoluteString) + "?authuser=\(urlEncodedAccount)")!
           }
           meetingLink = detectedLink
           break
       }
    }
  3. Custom Regex for Identifying Links: You can define custom regex patterns for identifying meeting links under the "Advanced" preferences tab. This allows you to add, edit, and save custom regex patterns for meeting links.

    "preferences_advanced_regex_title" = "Custom regex for meeting link";
    "preferences_advanced_regex_add_button" = "Add regex";
    "preferences_advanced_regex_edit_button" = "Edit";
    "preferences_advanced_regex_new_title" = "Enter regex";
    "preferences_advanced_regex_new_cant_save_title" = "Cannot save regex";
  4. Display the Correct Icon: To ensure the correct icon is displayed for the Teams link, modify the getIconForMeetingService function to use the appropriate image name for the Teams case.

    func getIconForMeetingService(_ meetingService: MeetingServices?) -> NSImage {
       var image = NSImage(named: "no_online_session")!
       image.size = NSSize(width: 16, height: 16)
    
       switch meetingService {
       case .some(.teams):
           image = NSImage(named: "ms_teams_icon")!
           image.size = NSSize(width: 16, height: 16)
       default:
           break
       }
    
       return image
    }

By following these steps, MeetingBar should correctly identify and prioritize the Microsoft Teams link that opens directly to the meeting and display the appropriate icon [1][2][[3]](https://github.com/leits/MeetingBar/blob/master/MeetingBar/Resources /Localization /en.lproj/Localizable.strings).

To continue talking to Dosu, mention @dosu.

GitHub
File not found · leits/MeetingBar
🇺🇦 Your meetings at your fingertips in the macOS menu bar - File not found · leits/MeetingBar
kamarianakis commented 2 weeks ago

Hello all, As I am also dealing with the same issue, on a Mac, where can/should I edit this things/files? I see the respective files on github but how should I proceed, as I am using the compiled version 4.1.0. Can it be done via the settings of the application? Many thanks!