Skip to content

Commit

Permalink
✨ Add teams service
Browse files Browse the repository at this point in the history
  • Loading branch information
oschrenk committed Jan 19, 2025
1 parent 58b0f15 commit e8d3013
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions Docs/Services.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ At the moment these service are supported

These are probably the most used services

- Discord
- Facetime
- GoToMeeting
- Microsoft Teams
- Phone

## Resources
Expand Down
3 changes: 2 additions & 1 deletion Sources/Model/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import ArgumentParser
import Foundation

enum Service: String, Codable, ExpressibleByArgument {
case ical, meet, zoom
case ical, meet, zoom, teams

private static let servicePatterns: [Service: String] = [
Service.meet: #"https:\/\/meet\.google\.com/[a-z]{3}-[a-z]{4}-[a-z]{3}"#,
Service.zoom: #"https://(?:[a-zA-Z0-9-.]+)?zoom\.(?:us|com|com\.cn|de)\/(?:my|[a-z]{1,2}|webinar)\/[-a-zA-Z0-9()@:%_\+.~#?&=\/]*"#,
Service.teams: #"https:\/\/teams\.microsoft\.com\/l\/meetup-join\/[a-zA-Z0-9_%\/=\-\+\.?]+"#,
]

private static func findMatch(in text: String, using pattern: String) -> String? {
Expand Down
8 changes: 8 additions & 0 deletions Tests/ServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ import Testing

#expect(output == expected)
}

@Test func testTeamsNotes() {
let input = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_MzI2YmRlNTgtMTU0MC00NmNhLWIzMmQtODg0ZGVmMGEwOTc3%40thread.v2/0?context=%7b%22Tid%22%3a%22c2ad6337-37a8-446a-ba48-18f44ea87c3d%22%2c%22Oid%22%3a%2230e7d7d2-057e-4d2f-8fa5-0475c962dded%22%7d"
let output = Service.fromNotes(notes: input)
let expected: [Service: String] = [Service.teams: input]

#expect(output == expected)
}
}

0 comments on commit e8d3013

Please sign in to comment.