selfsdk 0.0.224 → 0.0.225

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 603c5c25f0cfd0f1d5e4fd8d9912c15b2d279fbbe954b60eda27ee2fae116631
4
- data.tar.gz: 1c78db36346a7a4bf10350c0d87c12b75b990c729cd22b2ae1e83d30aeade199
3
+ metadata.gz: a3984e978f7582e2bd3840787766747f29417a08835f7c0c7e8c88791ca6ec4e
4
+ data.tar.gz: 1b52143809c1551df704cc2b686577fa163aa284b9ac52ec082ccec752ef944c
5
5
  SHA512:
6
- metadata.gz: 45f2d8427c79febc037f4e918fd8e6e24b8c1e08ffdc66567b1a33f602857737dedb2ceabf457c2adb814822697a3025f3499db2bb11acefc2200cd31144f80b
7
- data.tar.gz: ea5d5a7ea4ed98cac59f78f5ca6552e8f48236215c72203dbc22bf7df063a0f555a7143b7b3de87b0b00b22d2bc871ba08d32f46ccefd3380698881bdfdaa349
6
+ metadata.gz: 20d79f18d45c07c0ba2a35faa54db04a85833f541e4276ee6513db5b295d120c4e3d286dc7c81ca409669091cca2f1abf3c989dbba80aef4aab7eace4cf711b7
7
+ data.tar.gz: f88e9169c678a9914b4d1d730269d8e78d984ec9dbbdcd8a15bbac6c7c2f02a69912ca0eea238aa4b8783c85843717b4cc37f24233f766a95111a236ee40e989
@@ -57,9 +57,22 @@ module SelfSDK
57
57
  @facts.select{|f| f.name == name}.first
58
58
  end
59
59
 
60
+
61
+ # Returns an attestation by name
62
+ #
63
+ # @param name [String] the name of the fact to retrieve the attestation for
64
+ # @return [Object, nil] the first attestation of the fact, or nil if no fact is found
65
+ def attestation(name)
66
+ f = fact(name)
67
+ return nil if f.nil?
68
+
69
+ f.attestations.first
70
+ end
71
+
60
72
  def attestations_for(name)
61
73
  f = fact(name)
62
74
  return [] if f.nil?
75
+
63
76
  f.attestations
64
77
  end
65
78
 
data/lib/services/chat.rb CHANGED
@@ -52,7 +52,7 @@ module SelfSDK
52
52
  cm.mark_as_delivered unless opts[:mark_as_delivered] == false
53
53
  cm.mark_as_read if opts[:mark_as_read] == true
54
54
 
55
- block.call(cm)
55
+ call(block, cm)
56
56
  end
57
57
  end
58
58
 
@@ -104,19 +104,19 @@ module SelfSDK
104
104
  def on_invite(&block)
105
105
  @messaging.subscribe :chat_invite do |msg|
106
106
  g = SelfSDK::Chat::Group.new(self, msg.payload)
107
- block.call(g)
107
+ call(block, g)
108
108
  end
109
109
  end
110
110
 
111
111
  def on_join(&block)
112
112
  @messaging.subscribe :chat_join do |msg|
113
- block.call(iss: msg.payload[:iss], gid: msg.payload[:gid])
113
+ call(block, {iss: msg.payload[:iss], gid: msg.payload[:gid]})
114
114
  end
115
115
  end
116
116
 
117
117
  def on_leave(&block)
118
118
  @messaging.subscribe :chat_remove do |msg|
119
- block.call(iss: msg.payload[:iss], gid: msg.payload[:gid])
119
+ call(block, {iss: msg.payload[:iss], gid: msg.payload[:gid]})
120
120
  end
121
121
  end
122
122
 
@@ -194,7 +194,7 @@ module SelfSDK
194
194
  # @yield [request] Invokes the block with a connection response message.
195
195
  def on_connection(&block)
196
196
  @messaging.subscribe :connection_response do |msg|
197
- block.call(msg)
197
+ call(block, msg)
198
198
  end
199
199
  end
200
200
 
@@ -243,6 +243,17 @@ module SelfSDK
243
243
  posterior_members = true if m == @app_id
244
244
  end
245
245
  end
246
+
247
+ def call(block, *args)
248
+ block.call(*args)
249
+ rescue StandardError => e
250
+ SelfSDK.logger.error("A StandardError occurred: #{e.message}")
251
+ SelfSDK.logger.error("Backtrace:\n\t#{e.backtrace.join("\n\t")}")
252
+ rescue Exception => e
253
+ SelfSDK.logger.error("An unexpected exception occurred: #{e.message}")
254
+ SelfSDK.logger.error("Backtrace:\n\t#{e.backtrace.join("\n\t")}")
255
+ end
256
+
246
257
  end
247
258
  end
248
259
  end
@@ -29,7 +29,7 @@ module SelfSDK
29
29
  # Subscribes to chat.voice.setup messages.
30
30
  def on_setup(&block)
31
31
  @messaging.subscribe :voice_setup do |msg|
32
- block.call(msg.payload[:iss], msg.payload[:cid], msg.payload[:data])
32
+ call(block, msg.payload[:iss], msg.payload[:cid], msg.payload[:data])
33
33
  end
34
34
  end
35
35
 
@@ -46,17 +46,18 @@ module SelfSDK
46
46
  # Subscribes to chat.voice.start messages.
47
47
  def on_start(&block)
48
48
  @messaging.subscribe :voice_start do |msg|
49
- block.call(msg.payload[:iss],
50
- cid: msg.payload[:cid],
51
- call_id: msg.payload[:call_id],
52
- peer_info: msg.payload[:peer_info],
53
- data: msg.payload[:data])
49
+ call(block,
50
+ msg.payload[:iss],
51
+ cid: msg.payload[:cid],
52
+ call_id: msg.payload[:call_id],
53
+ peer_info: msg.payload[:peer_info],
54
+ data: msg.payload[:data])
54
55
  end
55
56
  end
56
57
 
57
58
  # Sends a chat.voice.accept message accepting a specific call.
58
59
  def accept(recipient, cid, call_id, peer_info)
59
- payload = {
60
+ payload = {
60
61
  typ: SelfSDK::Messages::VoiceAccept::MSG_TYPE,
61
62
  cid: cid,
62
63
  call_id: call_id,
@@ -68,16 +69,17 @@ module SelfSDK
68
69
  # Subscribes to chat.voice.accept messages.
69
70
  def on_accept(&block)
70
71
  @messaging.subscribe :voice_accept do |msg|
71
- block.call(msg.payload[:iss],
72
- cid: msg.payload[:cid],
73
- call_id: msg.payload[:call_id],
74
- peer_info: msg.payload[:peer_info])
72
+ call(block,
73
+ msg.payload[:iss],
74
+ cid: msg.payload[:cid],
75
+ call_id: msg.payload[:call_id],
76
+ peer_info: msg.payload[:peer_info])
75
77
  end
76
78
  end
77
79
 
78
80
  # Sends a chat.voice.accept message finishing the call.
79
81
  def stop(recipient, cid, call_id)
80
- payload = {
82
+ payload = {
81
83
  typ: SelfSDK::Messages::VoiceStop::MSG_TYPE,
82
84
  cid: cid,
83
85
  call_id: call_id,
@@ -88,10 +90,11 @@ module SelfSDK
88
90
  # Subscribes to chat.voice.stop messages.
89
91
  def on_stop(&block)
90
92
  @messaging.subscribe :voice_stop do |msg|
91
- block.call(msg.payload[:iss],
92
- cid: msg.payload[:cid],
93
- call_id: msg.payload[:call_id],
94
- peer_info: msg.payload[:peer_info])
93
+ call(block,
94
+ msg.payload[:iss],
95
+ cid: msg.payload[:cid],
96
+ call_id: msg.payload[:call_id],
97
+ peer_info: msg.payload[:peer_info])
95
98
  end
96
99
  end
97
100
 
@@ -106,10 +109,11 @@ module SelfSDK
106
109
  # Subscribes to chat.voice.busy messages.
107
110
  def on_busy(&block)
108
111
  @messaging.subscribe :voice_busy do |msg|
109
- block.call(msg.payload[:iss],
110
- cid: msg.payload[:cid],
111
- call_id: msg.payload[:call_id],
112
- peer_info: msg.payload[:peer_info])
112
+ call(block,
113
+ msg.payload[:iss],
114
+ cid: msg.payload[:cid],
115
+ call_id: msg.payload[:call_id],
116
+ peer_info: msg.payload[:peer_info])
113
117
  end
114
118
  end
115
119
 
@@ -124,10 +128,11 @@ module SelfSDK
124
128
  # Subscribes to chat.voice.summary messages.
125
129
  def on_summary(&block)
126
130
  @messaging.subscribe :voice_summary do |msg|
127
- block.call(msg.payload[:iss],
128
- cid: msg.payload[:cid],
129
- call_id: msg.payload[:call_id],
130
- peer_info: msg.payload[:peer_info])
131
+ call(block,
132
+ msg.payload[:iss],
133
+ cid: msg.payload[:cid],
134
+ call_id: msg.payload[:call_id],
135
+ peer_info: msg.payload[:peer_info])
131
136
  end
132
137
  end
133
138
 
@@ -142,6 +147,17 @@ module SelfSDK
142
147
  end
143
148
  m
144
149
  end
150
+
151
+ def call(block, *args)
152
+ block.call(*args)
153
+ rescue StandardError => e
154
+ SelfSDK.logger.error("A StandardError occurred: #{e.message}")
155
+ SelfSDK.logger.error("Backtrace:\n\t#{e.backtrace.join("\n\t")}")
156
+ rescue Exception => e
157
+ SelfSDK.logger.error("An unexpected exception occurred: #{e.message}")
158
+ SelfSDK.logger.error("Backtrace:\n\t#{e.backtrace.join("\n\t")}")
159
+ end
160
+
145
161
  end
146
162
  end
147
163
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.224
4
+ version: 0.0.225
5
5
  platform: ruby
6
6
  authors:
7
7
  - Self Group Ltd.