chat_sdk-gchat 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chat_sdk/gchat/adapter.rb +21 -0
- data/lib/chat_sdk/gchat/format_converter.rb +9 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 984169b648bea3c51b7726019d93035f884d3229e3cab76d183d89bafdd8d2e0
|
|
4
|
+
data.tar.gz: df8107d2939c79638eb19e72f556f3b418022edb3edf92fda051396d1f4ec6e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3162edf9dc5b8f504c5a6f470b912282f232a69b1a18cef895c01ca1c03b03f7d6ba7d952e3e0dad951259aeb0fca1c9b221bebed31539101c24a256b3ea387
|
|
7
|
+
data.tar.gz: 9ac83233af904d852c3706b73b6694ba0b78a03997782923def45689e8bb417e84eca20c166c28d6d4843c760647d360a7522b4a29dd74464582fcd6671f8df9
|
|
@@ -43,6 +43,27 @@ module ChatSDK
|
|
|
43
43
|
[]
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# Parses a Google Cloud Pub/Sub push message containing a Google Chat event.
|
|
47
|
+
#
|
|
48
|
+
# When a Pub/Sub subscription is configured externally (via Google Cloud
|
|
49
|
+
# Console or Terraform) for Google Workspace Events, push messages arrive
|
|
50
|
+
# as HTTP POSTs with the Chat event base64-encoded inside
|
|
51
|
+
# `message.data`. This method decodes the envelope and delegates to
|
|
52
|
+
# {EventParser}.
|
|
53
|
+
#
|
|
54
|
+
# @param rack_request [Rack::Request] the incoming Pub/Sub push request
|
|
55
|
+
# @return [Array<ChatSDK::Events::Base>] parsed events (empty on bad payload)
|
|
56
|
+
def parse_pubsub_event(rack_request)
|
|
57
|
+
envelope = read_json_body(rack_request)
|
|
58
|
+
data = envelope.dig("message", "data")
|
|
59
|
+
return [] unless data
|
|
60
|
+
|
|
61
|
+
decoded = JSON.parse(Base64.decode64(data))
|
|
62
|
+
EventParser.parse(decoded)
|
|
63
|
+
rescue JSON::ParserError, ArgumentError
|
|
64
|
+
[]
|
|
65
|
+
end
|
|
66
|
+
|
|
46
67
|
# Outbound
|
|
47
68
|
def post_message(channel_id:, message:, thread_id: nil)
|
|
48
69
|
msg = ChatSDK::PostableMessage.from(message)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chat_sdk-gchat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Quentin Rousseau
|
|
@@ -62,6 +62,7 @@ files:
|
|
|
62
62
|
- lib/chat_sdk/gchat/adapter.rb
|
|
63
63
|
- lib/chat_sdk/gchat/card_v2_renderer.rb
|
|
64
64
|
- lib/chat_sdk/gchat/event_parser.rb
|
|
65
|
+
- lib/chat_sdk/gchat/format_converter.rb
|
|
65
66
|
- lib/chat_sdk/gchat/resource_name.rb
|
|
66
67
|
- lib/chat_sdk/gchat/token_verifier.rb
|
|
67
68
|
homepage: https://github.com/rootlyhq/chat-sdk
|