Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(outlook): minor manifest fixes #235

Merged
merged 9 commits into from
Nov 2, 2022
Merged
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
10 changes: 5 additions & 5 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ shards:

bindata:
git: https://github.com/spider-gazelle/bindata.git
version: 1.11.0
version: 1.11.1

clear:
git: https://github.com/place-labs/clear.git
Expand Down Expand Up @@ -145,9 +145,9 @@ shards:
git: https://github.com/wyhaines/opentelemetry-api.cr.git
version: 0.5.0

opentelemetry-instrumentation:
git: https://github.com/wyhaines/opentelemetry-instrumentation.cr.git
version: 0.5.0+git.commit.7d83b9a53c9540fbc159f06eeed5d4bdad5c4377
opentelemetry-instrumentation: # Overridden
git: https://github.com/stakach/opentelemetry-instrumentation.cr.git
version: 0.5.0+git.commit.8dc0a4ed085ab8f928b3681990676d818ea9db6d

opentelemetry-sdk:
git: https://github.com/wyhaines/opentelemetry-sdk.cr.git
Expand Down Expand Up @@ -179,7 +179,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 8.12.1
version: 8.12.2

promise:
git: https://github.com/spider-gazelle/promise.git
Expand Down
4 changes: 4 additions & 0 deletions shard.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ dependencies:
db:
github: place-labs/crystal-db
branch: master

opentelemetry-instrumentation:
github: stakach/opentelemetry-instrumentation.cr
branch: patch-1
57 changes: 57 additions & 0 deletions spec/models/tenant_outlook_config_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require "../spec_helper"

describe Tenant::OutlookConfig do
it "#clean sets blank strings to nil" do
config = Tenant::OutlookConfig.from_json({
app_id: " ",
base_path: " ",
app_domain: " ",
app_resource: " ",
source_location: " ",
}.to_json)

clean_config = config.clean

clean_config.app_id.should eq("")
clean_config.base_path.should be_nil
clean_config.app_domain.should be_nil
clean_config.app_resource.should be_nil
clean_config.source_location.should be_nil
end

it "#clean removes leading and trailing whitespace" do
config = Tenant::OutlookConfig.from_json({
app_id: " qwer-asdf-zxcv ",
base_path: " inlook ",
app_domain: " https://tenant.example.com/inlook/ ",
app_resource: " api://tenant.example.com/qwer-asdf-zxcv ",
source_location: " https://tenant.example.com/inlook/ ",
}.to_json)

clean_config = config.clean

clean_config.app_id.should eq("qwer-asdf-zxcv")
clean_config.base_path.should eq("inlook")
clean_config.app_domain.should eq("https://tenant.example.com/inlook/")
clean_config.app_resource.should eq("api://tenant.example.com/qwer-asdf-zxcv")
clean_config.source_location.should eq("https://tenant.example.com/inlook/")
end

it "#clean changes uppercase to downcase" do
config = Tenant::OutlookConfig.from_json({
app_id: " QWER-ASDF-ZXCV ",
base_path: " InLook ",
app_domain: " HTTPS://tenant.example.com/inlook/ ",
app_resource: " API://tenant.example.com/QWER-ASDF-ZXCV ",
source_location: " HTTPS://tenant.example.com/inlook/ ",
}.to_json)

clean_config = config.clean

clean_config.app_id.should eq("qwer-asdf-zxcv")
clean_config.base_path.should eq("inlook")
clean_config.app_domain.should eq("https://tenant.example.com/inlook/")
clean_config.app_resource.should eq("api://tenant.example.com/qwer-asdf-zxcv")
clean_config.source_location.should eq("https://tenant.example.com/inlook/")
end
end
3 changes: 2 additions & 1 deletion src/controllers/outlook.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Outlook < ActionController::Base
function_file_url: "https://#{tenant.domain}/#{base_path}/function-file/function-file.html",
taskpane_url: "https://#{tenant.domain}/#{base_path}/#/book/meeting",
rooms_button_url: "https://#{tenant.domain}/#{base_path}/#/upcoming",
desks_button_url: "https://#{tenant.domain}/#{base_path}/#/book/desks"
desks_button_url: "https://#{tenant.domain}/#{base_path}/#/book/desks",
version: (tenant.updated_at.to_unix || tenant.created_at.to_unix).to_s,
)

render xml: manifest.to_xml
Expand Down
164 changes: 83 additions & 81 deletions src/models/outlook_manifest.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct OutlookManifest
property taskpane_url : String
property rooms_button_url : String
property desks_button_url : String
property version : String

def initialize(
@app_id,
Expand All @@ -18,7 +19,8 @@ struct OutlookManifest
@function_file_url,
@taskpane_url,
@rooms_button_url,
@desks_button_url
@desks_button_url,
@version
)
end

Expand All @@ -33,7 +35,7 @@ struct OutlookManifest
"xsi:type": "MailApp"
) do
xml.element("Id") { xml.text UUID.random.to_s }
xml.element("Version") { xml.text "1.0.1.0" }
xml.element("Version") { xml.text @version }
xml.element("ProviderName") { xml.text "PLACEOS" }
xml.element("DefaultLocale") { xml.text "en-US" }
xml.element("DisplayName", "DefaultValue": "PlaceOS | Book Meeting Plugin")
Expand Down Expand Up @@ -67,102 +69,102 @@ struct OutlookManifest
end
xml.element("DisableEntityHighlighting") { xml.text "false" }
xml.element("VersionOverrides", "xmlns": "http://schemas.microsoft.com/office/mailappversionoverrides", "xsi:type": "VersionOverridesV1_0") do
xml.element("Requirements") do
xml.element("bt:Sets", "DefaultMinVersion": "1.3") do
xml.element("bt:Set", "Name": "Mailbox")
xml.element("VersionOverrides", "xmlns": "http://schemas.microsoft.com/office/mailappversionoverrides/1.1", "xsi:type": "VersionOverridesV1_1") do
xml.element("Requirements") do
xml.element("bt:Sets", "DefaultMinVersion": "1.6") do
xml.element("bt:Set", "Name": "Mailbox")
end
end
end
xml.element("Hosts") do
xml.element("Host", "xsi:type": "MailHost") do
xml.element("DesktopFormFactor") do
xml.element("FunctionFile", "resid": "functionFile")
xml.element("ExtensionPoint", "xsi:type": "AppointmentOrganizerCommandSurface") do
xml.element("OfficeTab", "id": "TabDefault") do
xml.element("Group", "id": "msgReadGroup") do
xml.element("Label", "resid": "GroupLabel")
xml.element("Control", "xsi:type": "Button", "id": "msgReadOpenPaneButton") do
xml.element("Label", "resid": "TaskpaneButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "TaskpaneButton.Label")
xml.element("Description", "resid": "TaskpaneButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "Taskpane.Url")
end
end
xml.element("Control", "xsi:type": "Button", "id": "RoomsButton") do
xml.element("Label", "resid": "RoomsButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "RoomsButton.Label")
xml.element("Description", "resid": "RoomsButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "RoomsButton.Url")
xml.element("Hosts") do
xml.element("Host", "xsi:type": "MailHost") do
xml.element("DesktopFormFactor") do
xml.element("FunctionFile", "resid": "functionFile")
xml.element("ExtensionPoint", "xsi:type": "AppointmentOrganizerCommandSurface") do
xml.element("OfficeTab", "id": "TabDefault") do
xml.element("Group", "id": "msgReadGroup") do
xml.element("Label", "resid": "GroupLabel")
xml.element("Control", "xsi:type": "Button", "id": "msgReadOpenPaneButton") do
xml.element("Label", "resid": "TaskpaneButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "TaskpaneButton.Label")
xml.element("Description", "resid": "TaskpaneButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "Taskpane.Url")
end
end
end
xml.element("Control", "xsi:type": "Button", "id": "DesksButton") do
xml.element("Label", "resid": "DesksButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "DesksButton.Label")
xml.element("Description", "resid": "DesksButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
xml.element("Control", "xsi:type": "Button", "id": "RoomsButton") do
xml.element("Label", "resid": "RoomsButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "RoomsButton.Label")
xml.element("Description", "resid": "RoomsButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "RoomsButton.Url")
end
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "DesksButton.Url")
xml.element("Control", "xsi:type": "Button", "id": "DesksButton") do
xml.element("Label", "resid": "DesksButton.Label")
xml.element("Supertip") do
xml.element("Title", "resid": "DesksButton.Label")
xml.element("Description", "resid": "DesksButton.Tooltip")
end
xml.element("Icon") do
xml.element("bt:Image", "size": "16", "resid": "Icon.16x16")
xml.element("bt:Image", "size": "32", "resid": "Icon.32x32")
xml.element("bt:Image", "size": "80", "resid": "Icon.80x80")
end
xml.element("Action", "xsi:type": "ShowTaskpane") do
xml.element("SourceLocation", "resid": "DesksButton.Url")
end
end
end
end
end
end
end
end
end
xml.element("Resources") do
xml.element("bt:Images") do
xml.element("bt:Image", "id": "Icon.16x16", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/16x16-01.png")
xml.element("bt:Image", "id": "Icon.32x32", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/32x32-01.png")
xml.element("bt:Image", "id": "Icon.80x80", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/80x80-01.png")
end
xml.element("bt:Urls") do
xml.element("bt:Url", "id": "functionFile", "DefaultValue": @function_file_url)
xml.element("bt:Url", "id": "Taskpane.Url", "DefaultValue": @taskpane_url)
xml.element("bt:Url", "id": "RoomsButton.Url", "DefaultValue": @rooms_button_url)
xml.element("bt:Url", "id": "DesksButton.Url", "DefaultValue": @desks_button_url)
end
xml.element("bt:ShortStrings") do
xml.element("bt:String", "id": "GroupLabel", "DefaultValue": "PlaceOS | Book Meeting")
xml.element("bt:String", "id": "TaskpaneButton.Label", "DefaultValue": "Book a meeting")
xml.element("bt:String", "id": "DesksButton.Label", "DefaultValue": "Book a Desk")
xml.element("bt:String", "id": "RoomsButton.Label", "DefaultValue": "Upcoming meetings")
end
xml.element("bt:LongStrings") do
xml.element("bt:String", "id": "TaskpaneButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
xml.element("bt:String", "id": "DesksButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
xml.element("bt:String", "id": "RoomsButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
xml.element("Resources") do
xml.element("bt:Images") do
xml.element("bt:Image", "id": "Icon.16x16", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/16x16-01.png")
xml.element("bt:Image", "id": "Icon.32x32", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/32x32-01.png")
xml.element("bt:Image", "id": "Icon.80x80", "DefaultValue": "https://s3.ap-southeast-2.amazonaws.com/os.place.tech/outlook-plugin-resources/80x80-01.png")
end
xml.element("bt:Urls") do
xml.element("bt:Url", "id": "functionFile", "DefaultValue": @function_file_url)
xml.element("bt:Url", "id": "Taskpane.Url", "DefaultValue": @taskpane_url)
xml.element("bt:Url", "id": "RoomsButton.Url", "DefaultValue": @rooms_button_url)
xml.element("bt:Url", "id": "DesksButton.Url", "DefaultValue": @desks_button_url)
end
xml.element("bt:ShortStrings") do
xml.element("bt:String", "id": "GroupLabel", "DefaultValue": "PlaceOS | Book Meeting")
xml.element("bt:String", "id": "TaskpaneButton.Label", "DefaultValue": "Book a meeting")
xml.element("bt:String", "id": "DesksButton.Label", "DefaultValue": "Book a Desk")
xml.element("bt:String", "id": "RoomsButton.Label", "DefaultValue": "Upcoming meetings")
end
xml.element("bt:LongStrings") do
xml.element("bt:String", "id": "TaskpaneButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
xml.element("bt:String", "id": "DesksButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
xml.element("bt:String", "id": "RoomsButton.Tooltip", "DefaultValue": "Opens a pane displaying all available properties.")
end
end
end
xml.element("VersionOverrides", "xmlns": "http://schemas.microsoft.com/office/mailappversionoverrides/1.1", "xsi:type": "VersionOverridesV1_1") do
xml.element("WebApplicationInfo") do
xml.element("Id") { xml.text @app_id }
xml.element("Resource") { xml.text @app_resource }
xml.element("Scopes") do
xml.element("Scope") { xml.text "User.Read" }
xml.element("Scope") { xml.text "profile" }
xml.element("Scope") { xml.text "openid" }
xml.element("Scope") { xml.text "User.Read" }
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions src/models/tenant.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class Tenant
has_many guests : Guest, foreign_key: "tenant_id"
has_many event_metadata : EventMetadata, foreign_key: "tenant_id"

timestamps

before :save, :set_delegated
before :save, :encrypt!

Expand Down
12 changes: 11 additions & 1 deletion src/models/tenant/outlook_config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class Tenant
property app_resource : String?
property source_location : String?

def clean
config = self
config.app_id = config.app_id.strip.downcase
config.base_path = (c = config.base_path) && !c.blank? ? c.strip.downcase : nil
config.app_domain = (c = config.app_domain) && !c.blank? ? c.strip.downcase : nil
config.app_resource = (c = config.app_resource) && !c.blank? ? c.strip.downcase : nil
config.source_location = (c = config.source_location) && !c.blank? ? c.strip.downcase : nil
config
end

def params
{
app_id: @app_id,
Expand Down Expand Up @@ -37,7 +47,7 @@ class Tenant
end

def self.to_db(x : OutlookConfig?)
x.to_json
x.nil? ? x.to_json : x.clean.to_json
end
end
end
Expand Down