Skip to content

Commit

Permalink
cal origin
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Feb 28, 2023
1 parent a58cc34 commit 208dbe0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/services/message_apis/cal/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class Api < MessageApis::BasePackage

def initialize(config:)
@api_token = config["api_key"]
@base_url = config["url"].presence || "https://api.cal.com/api/v1"
@base_url = "https://api.cal.com/api/v1"
@key = config["key"]
@package = config[:package]
@domain_url = config["domain_url"].presence

@conn = Faraday.new request: {
params_encoder: Faraday::FlatParamsEncoder
Expand Down
10 changes: 6 additions & 4 deletions app/services/message_apis/cal/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def self.configure_hook(kind:, ctx:)
end

event_types = ctx[:package].message_api_klass.event_types.filter { |o| !o["hidden"] }
# Rails.logger.debug event_types

{
kind: "configure",
definitions: [
Expand Down Expand Up @@ -149,6 +149,8 @@ def self.sheet_view(params)
calendar_name = params["package"].settings["calendar_name"]
@cal_link = "#{calendar_name}/#{event_type}"

@cal_domain = params["package"].settings["domain_url"].presence || "https://cal.com"

template = ERB.new <<~SHEET_VIEW
<html lang="en">
<head>
Expand Down Expand Up @@ -189,8 +191,8 @@ def self.sheet_view(params)
}
p(cal, ar);
};
})(window, "https://cal.com/embed.js", "init");
Cal("init")
})(window, "#{@cal_domain}/embed/embed.js", "init");
Cal("init", {origin: "#{@cal_domain}"})
</script>
</head>
Expand All @@ -208,7 +210,7 @@ def self.sheet_view(params)
email: "#{@user&.email}", // Prefill Email
// notes: "Chaskiq Meeting", // Prefill Notes
// guests: ["janedoe@gmail.com", "test@gmail.com"], // Prefill Guests
theme: "light", // "dark" or "light" theme
theme: "light", // "dark" or "light" theme,
},
//metadata: {
// bb: 123,
Expand Down
4 changes: 2 additions & 2 deletions lib/app_packages_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ def self.packages(dev_packages: false)
grid: { xs: "w-full", sm: "w-full" }
},
{
name: "url",
name: "domain_url",
type: "string",
hint: "defaults to cal.com api",
hint: "instance domain url for embed defaults to cal.com",
required: false,
grid: { xs: "w-full", sm: "w-full" }
}
Expand Down

0 comments on commit 208dbe0

Please sign in to comment.