better error on jmp-fwdcall's new "anonymous" JIDs

Denver Gingerich created

When the user tries to send a message to an "anonymous" JID (the type
of JID that jmp-fwdcalls will create when it gets a blocked caller ID,
as of https://gitlab.com/ossguy/jmp-fwdcalls/commit/e2032c8 anyway)
provide a more appropriate error message, as the JID does exist, it's
just that the user who left the voicemail isn't available at that JID.

Change summary

sgx-catapult.rb | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

Detailed changes

sgx-catapult.rb 🔗

@@ -46,6 +46,11 @@ def extract_shortcode(dest)
 	num if context && context == 'phone-context=ca-us.phone-context.soprani.ca'
 end
 
+def is_anonymous_tel?(dest)
+	num, context = dest.split(';', 2)
+	context && context == 'phone-context=anonymous.phone-context.soprani.ca'
+end
+
 class SGXClient < Blather::Client
 	def register_handler(type, *guards, &block)
 		super(type, *guards) { |*args| wrap_handler(*args, &block) }
@@ -267,8 +272,13 @@ module SGXcatapult
 				shortcode = extract_shortcode(num_dest)
 				next shortcode if shortcode
 			end
-			# TODO: text re num not (yet) supportd/implmentd
-			EMPromise.reject([:cancel, 'item-not-found'])
+
+			if is_anonymous_tel?(num_dest)
+				EMPromise.reject([:cancel, 'gone'])
+			else
+				# TODO: text re num not (yet) supportd/implmentd
+				EMPromise.reject([:cancel, 'item-not-found'])
+			end
 		}
 	end