Only count billable messages

Stephen Paul Weber created

Not typing indicators, etc.

Change summary

sgx_jmp.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Detailed changes

sgx_jmp.rb 🔗

@@ -167,6 +167,10 @@ end
 # Especially if we have the component join MUC for notifications
 message(to: /\A#{CONFIG[:component][:jid]}\Z/) {}
 
+def billable_message(m)
+	!m.body.empty? || m.find("ns:x", ns: OOB.registered_ns).first
+end
+
 message do |m|
 	sentry_hub = new_sentry_hub(m, name: "message")
 	today = Time.now.utc.to_date
@@ -177,7 +181,7 @@ message do |m|
 		)
 		EMPromise.all([
 			customer,
-			customer.incr_message_usage,
+			(customer.incr_message_usage if billable_message(m)),
 			REDIS.exists("jmp_usage_notify-#{customer.customer_id}"),
 			customer.stanza_from(m)
 		])