Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions drivers/place/calendar_common.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}" }

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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|
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading