diff --git a/drivers/place/calendar_common.cr b/drivers/place/calendar_common.cr index a30f10c8490..3f27af4c486 100644 --- a/drivers/place/calendar_common.cr +++ b/drivers/place/calendar_common.cr @@ -80,7 +80,7 @@ module Place::CalendarCommon end end - protected def client + protected def client(&) # office365 execute queries against the users mailbox and hence doesn't require rate limiting if @client.not_nil!.client_id == :office365 return yield(@client.not_nil!) @@ -131,7 +131,7 @@ module Place::CalendarCommon cc : String | Array(String) = [] of String, bcc : String | Array(String) = [] of String, from : String | Array(String) | Nil = nil, - reply_to : String | Array(String) | Nil = nil + reply_to : String | Array(String) | Nil = nil, ) sender = case from in String @@ -176,7 +176,7 @@ module Place::CalendarCommon @[PlaceOS::Driver::Security(Level::Support)] def get_members( group_id : String, - next_page : String? = nil + next_page : String? = nil, ) logger.debug { "listing members of group: #{group_id}" } @@ -204,7 +204,7 @@ module Place::CalendarCommon query : String? = nil, limit : Int32? = nil, filter : String? = nil, - next_page : String? = nil + next_page : String? = nil, ) logger.debug { "listing user details, query #{query || filter}, limit #{limit} (next: #{!!next_page})" } users = client &.list_users(query, limit, filter: filter, next_link: next_page) @@ -243,7 +243,7 @@ module Place::CalendarCommon @[PlaceOS::Driver::Security(Level::Support)] def list_groups( query : String? = nil, - filter : String? = nil + filter : String? = nil, ) logger.debug { "listing groups, filtering by #{filter || query}, note: graphAPI only" } client do |_client| @@ -269,6 +269,40 @@ module Place::CalendarCommon end end + # NOTE:: GraphAPI Only! + @[PlaceOS::Driver::Security(Level::Support)] + def list_channel_messages(team_id : String, channel_id : String, filter : String? = nil, match : String? = nil, + top : Int32? = nil, skip : Int32? = nil, count : Bool? = nil) + logger.debug { "listing teams #{team_id} channel #{channel_id} messages , filtering by #{filter}, selecting #{match}, top #{top}, skip #{skip}, count #{count}, note: graphAPI only" } + client do |_client| + if _client.client_id == :office365 + _client.calendar.as(PlaceCalendar::Office365).client.list_channel_messages(team_id, channel_id, filter, match, top, skip, count) + end + end + end + + # NOTE:: GraphAPI Only! + @[PlaceOS::Driver::Security(Level::Support)] + def get_channel_message(team_id : String, channel_id : String, message_id : String) + logger.debug { "Getting teams #{team_id} channel #{channel_id} message id #{message_id}, note: graphAPI only" } + client do |_client| + if _client.client_id == :office365 + _client.calendar.as(PlaceCalendar::Office365).client.get_channel_message(team_id, channel_id, message_id) + end + end + end + + # NOTE:: GraphAPI Only! + @[PlaceOS::Driver::Security(Level::Support)] + def send_channel_message(team_id : String, channel_id : String, message : String, content_type : String = "HTML") + logger.debug { "Sending teams #{team_id} channel #{channel_id} content_type #{content_type}, message #{message}, note: graphAPI only" } + client do |_client| + if _client.client_id == :office365 + _client.calendar.as(PlaceCalendar::Office365).client.send_channel_message(team_id, channel_id, message, content_type) + end + end + end + @[PlaceOS::Driver::Security(Level::Support)] def list_events(calendar_id : String, period_start : Int64, period_end : Int64, time_zone : String? = nil, user_id : String? = nil, include_cancelled : Bool = false, ical_uid : String? = nil) location = time_zone ? Time::Location.load(time_zone) : Time::Location.local @@ -351,7 +385,7 @@ module Place::CalendarCommon online_meeting_url : String? = nil, online_meeting_sip : String? = nil, online_meeting_phones : Array(String)? = nil, - online_meeting_pin : String? = nil + online_meeting_pin : String? = nil, ) user_id = (user_id || @service_account.presence || calendar_id).not_nil! calendar_id = calendar_id || user_id diff --git a/shard.lock b/shard.lock index a990ba092f9..102d4bcd5ad 100644 --- a/shard.lock +++ b/shard.lock @@ -179,7 +179,7 @@ shards: office365: git: https://github.com/placeos/office365.git - version: 1.25.4 + version: 1.25.5 openssl_ext: git: https://github.com/spider-gazelle/openssl_ext.git