Commit log

0eb7d28 merge in "Put <error/> child first on error" fixes

Click to expand commit body
Some clients expect <error/> first and we should always set the type
to :error regardless.

See merge request !17 for the discussion and details behind the merge.

Denver Gingerich created

5cb3c43 Put <error/> child first on error

Click to expand commit body
Every error is of type error, and put the <error/> child first for
broken parsers that only get the first child.

Stephen Paul Weber created

26e6047 merge in "policy-violation" error on empty message

Click to expand commit body
This probably doesn't appear much in the wild, but good to have in
case we do see it.

See merge request !16 for the discussion and details behind the merge.

Denver Gingerich created

d09c242 Support any <message> with a body

Click to expand commit body
Empty and whitespace-only bodies are banned by catapult API, so return a
policy-violation error in those cases.

Closes #12

Stephen Paul Weber created

40f5a38 ec4342a (!12) regression fix; MMS needs multi-arg

Denver Gingerich created

87c554b + "Allow inserting Blather handler before others"

Click to expand commit body
Works well in my tests and, from my understanding, will be helpful in
fixing https://gitlab.com/ossguy/jmp-fwdcalls/issues/7 .

See merge request !15 for the discussion and details behind the merge.

Denver Gingerich created

0702410 Allow inserting Blather handler before others

Click to expand commit body
Mostly useful for extending the existing SGXcatapult application from
elsewhere.

Stephen Paul Weber created

7f104d5 merge in "Fix exception on ^C" - innocuous enough

Click to expand commit body
I don't normally kill sgx-catapult from the command-line so my tests
just cover use via Monit, but it worked fine in those tests so seems
good to merge.

See merge request !14 for the discussion and details behind the merge.

Denver Gingerich created

6166a87 merge in "Fix presence" - inactive code now active

Click to expand commit body
The unused `subscription(:request?) do |s|` section became used when
we switched Blather to stop processing a stanza on the first matched
Ruby proc in 6d19b7f.  It was added way back in the first week of
sgx-catapult development and hadn't been touched (or likely thought
of) since.  So it's about time we deleted it anyway.

This does cause subscription requests to work again in my testing.

See merge request !13 for the discussion and details behind the merge.

Denver Gingerich created

38b0797 Fix exception on ^C

Click to expand commit body
Defer the stop to happen outside of the trap handler so that EM won't
freak out about it.

Stephen Paul Weber created

9c0714a Fix presence

Click to expand commit body
There were two handlers -- the more specific one was commented out? And
now that we only run the first matching handler, this caused all
subscriptions to be eaten.

Stephen Paul Weber created

b208ffe merge the "Move send_media helper to SGXcatapult"

Click to expand commit body
Needed for https://gitlab.com/ossguy/jmp-fwdcalls/merge_requests/1 and
also adds optional subject and description parameters for filling in
the respective fields on the XMPP message (not used yet).

See merge request !10 for the discussion and details behind the merge.

Denver Gingerich created

695d6e5 Move send_media helper to SGXcatapult

Click to expand commit body
Makes more sense there, and gives others who want to use it easier
access.

Stephen Paul Weber created

3e67d2f fix 7729a26 so params remain out of log, as before

Click to expand commit body
As mentioned in 889024e, 7729a26 had the side-effect of adding the
params values to the log.  In the spirit of 349d8b0, we are trying to
keep such values out of the log, so explicitly remove them to retain
the old (and desired) behaviour.

Denver Gingerich created

889024e merge "Allow for others to plug-over us"; caveats:

Click to expand commit body
In 7729a26 the Redis parameters were moved such that the `REDIS_URL`
environment variable must now be used instead.

In 7729a26 a `use Goliath::Rack::Params` was added, which changes the
behaviour when printing the `env` in `response(env)`.  This will be
fixed in a later commit.

In 5f00e6d the XMPP features list advertised by sgx-catapult has been
fixed.  This is long overdue and good to have corrected at last.

See merge request !9 for the discussion and details behind the merge.

Denver Gingerich created

5f00e6d Allow others to augment what we report support for

Click to expand commit body
Also, remove advertisements of support for things we don't currently
support.

Stephen Paul Weber created

7729a26 Allow for others to plug-over us

Click to expand commit body
Defer executing the event loop until exit in case someone `require`s us
and wants to install extra stuff before we run.

Some small tweaks to the APIs to make the coming fwdcalls plugover
easier.

Also, normalise to use REDIS_URL environment variable instead of passing
host/port in args.

Stephen Paul Weber created

d4bb849 merge "Refactor register to use EM" - passes tests

Click to expand commit body
In particular, tested SMS send/receive (shouldn't have been impacted)
as well as the registration form display on an already-registered
account (using Cheogram's "Configure direct message route" ad-hoc
command).  Both appeared to work fine.  Since we don't currently use
much more than this in JMP (most registration is done behind the
scenes and Cheogram mainly uses registration for verification reasons)
that should be sufficient testing for now.

See merge request !8 for the discussion and details behind the merge.

Denver Gingerich created

6d19b7f Refactor register to use EM

Click to expand commit body
Now everything uses EM and there's no blocking IO!

Also, fixes stalls caused by Blather mixing threads with EM by default:
https://github.com/adhearsion/blather/issues/130
https://github.com/eventmachine/eventmachine/issues/779

Stephen Paul Weber created

ef5dc74 merge in proper IQ feature-not-implemented support

Click to expand commit body
The last one (!11) wasn't quite right, but with this #8 is now fixed.

See merge request !12 for the discussion and details behind the merge.

Denver Gingerich created

6f4f934 Return feature-not-implemented for unknown iq

Click to expand commit body
By default, blather treats both false and nil returns from a handler as
a signal to pass control to the next handler.  That's counter-intuitive,
so let's over-ride that and always stop after the first handler (unless
throw(:pass) is explicitly called).

Stephen Paul Weber created

ec4342a Refactor top-level error handling

Click to expand commit body
Catch everything that could happen in a handler, in every handler, and
panic if there's anything unhandled.

Stephen Paul Weber created

801faf8 Revert "On unknown IQ, reply with proper error"

Click to expand commit body
This reverts commit b5f8cc47d6eccf8214a653612527cbf76724385d.

Apparently blather is running the handlers for *all* iq, not just the
ones unhandled by others.

Stephen Paul Weber created

a17728a merge in "On unknown IQ, reply with proper error"

Click to expand commit body
Thanks to @singpolyma for both reporting (#8) and fixing this.

See merge request !11 for the discussion and details behind the merge.

Denver Gingerich created

b5f8cc4 On unknown IQ, reply with proper error

Click to expand commit body
Closes #8

Stephen Paul Weber created

03173c7 add copyright notice for a98b0f9 missed in c25ea8c

Denver Gingerich created

1ed11ad response output was lost in translation in ff64421

Click to expand commit body
In the pre-refactor code, response.to_s looks something like this:
"#<Net::HTTPOK:0x00000002b8dad8>".  After the refactor in ff64421 the
chosen replacement value (http.response) outputs the entire body of
the response instead, which is more than we're looking to log.  So
remove it entirely ("#<EventMachine::HttpClient:0x00000001d6b810>",
the value of http.to_s, is even less useful than response.to_s was)
and just print the response code on its own in that line now.

This happens to fix an 80-column violation introduced in ff64421 as
well, which we should probably have checked by RuboCop at some point.

Denver Gingerich created

8428742 relax some RuboCop restrictions; missed in 349d8b0

Denver Gingerich created

540712f merge in "Refactor mpx-catapult to use em_promise"

Click to expand commit body
Note that the EventMachine upgrade is required here since "1.0.1 fixes
a bug with the use of epoll, which goliath's runner enables", per the
merge discussion.

See merge request !7 for the discussion and details behind this merge.

Denver Gingerich created

ff64421 Refactor mpx-catapult to use em_promise

Click to expand commit body
Instead of writing our own, just use the built-in Goliath runner.
This changes the usage, new usage is:

REDIS_URL=redis://localhost:6379/0 bundle exec mpx-catapult.rb -p $PORT -s -v

There is a --help for more information (provided by Goliath).

Instead of using blocking I/O, use EventMachine.
To be consistent with the rest of the project, use em_promise

Stephen Paul Weber created

349d8b0 only print certain request fields - not all needed

Denver Gingerich created

c25ea8c add requisite copyright notice for a98b0f9 changes

Denver Gingerich created

a98b0f9 merge initial EventMachine refactor - passes tests

Click to expand commit body
This looks very good to me and worked fine in my testing (including
most of the cases that result in errors being returned to the user).
The changes should make sgx-catapult much more performant (especially
as we handle more load) and are generally the right thing to do.

There are a couple of minor fixes that are included in these changes
that would ideally be broken out into separate commits, but I won't
push for those here as the important part is the resulting code.

See merge request !6 for the discussion and details behind this merge.

Denver Gingerich created

85aa080 Refactor incoming callback redis code

Stephen Paul Weber created

dd7e711 Refactor the ibb file receive as well

Stephen Paul Weber created

a35693b Refactor the whole chat handler

Stephen Paul Weber created

429837b First HTTP request using em-http

Stephen Paul Weber created

366c568 don't crash on register <remove/>; implement later

Denver Gingerich created

c226d87 fix split: "undefined method `b' for nil:NilClass"

Denver Gingerich created

b1da90f don't hang on Exception; instead, log msg and quit

Click to expand commit body
This fix introduces several "C: Use 1 (not 0) spaces for indentation."
RuboCop offenses due to the introduction of begin/end blocks that seem
to be required inside each Ruby proc that needs a rescue section.
There wasn't an obvious RuboCop setting to disable, and it's probably
worth fixing in a better way eventually, so leave them in for now.

We did have to disable the RuboCop check for "rescue Exception", which
is used liberally in this commit.  In our situation, doing so is ok,
since we really do want to catch every single type of exception.  It's
fine to do so since we're exiting every time regardless of the issue.

Denver Gingerich created

8e473bb fix 777b17d indent - RuboCop doesn't check its cfg

Denver Gingerich created

9054cf1 as promised, use 449bb69 fix everywhere (iq close)

Denver Gingerich created

449bb69 merge "Should not crash if id or resource missing"

Click to expand commit body
This crash is particularly bad because it currently causes
sgx-catapult to get stuck.  We'll fix that in a future commit.  Also,
a future commit will apply this fix to the other tagged message send.

See merge request !5 for the discussion and details behind this merge.

Denver Gingerich created

b4c5749 Should not crash if id or resource missing

Click to expand commit body
Since id is not strictly required on messages, and bare JIDs can
certainly send message stanzas.

Stephen Paul Weber created

a8a3d6f unescape JID from URL - fixes Cheogram users' URLs

Denver Gingerich created

920259a merge "Use a standard gateway type" - XEP-0030 fix

Click to expand commit body
I must not have looked at the spec when I wrote this disco value; it
seems pretty clear that "sms" is indeed the right string to use:

https://xmpp.org/registrar/disco-categories.html#gateway

See merge request !4 for the discussion and details behind this merge.

Denver Gingerich created

9c33beb merge "Switch to SecureRandom.uuid" - sleeker deps

Click to expand commit body
This does not appear to have any functional changes so I'm happy to
merge something that gives us fewer dependencies.

See merge request !3 for the discussion and details behind this merge.

Denver Gingerich created

39ed61f Use a standard gateway type

Stephen Paul Weber created

47b643c Switch to SecureRandom.uuid

Click to expand commit body
Saves us a whole dependency!

Stephen Paul Weber created

f3ea0f3 treat identical registration as success; fixes #3

Click to expand commit body
Rather than always sending a <conflict/> error back if we encounter an
existing registration, we first check both the catapult_jid-<P> and
catapult_cred-<J> keys.  If either or both of them exist and at least
one has a different value than the user's, then we still return a
<conflict/> error.  Otherwise, we set the values that the user entered
and indicate a successful registration.

This has the added advantage of allowing a person to easily fix a
partial registration.  Such a thing is unlikely, but possible, given
that the setting of catapult_jid-<P> and catapult_cred-<J> are not in
the same transaction, and sgx-catapult could go down mid-registration.

Making this change was much easier thanks to the a66b574 refactoring.

Denver Gingerich created