Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental Zulip support #184

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb463cd
first draft of zulip module
aglasgall Jan 29, 2014
fa4c773
fix retries in Zulip module
aglasgall Jun 11, 2014
5afbccf
Better HTTPS support
aglasgall Nov 19, 2016
e25b189
add README
aglasgall Nov 19, 2016
7eda6b3
Add subscription manipulation
aglasgall Nov 19, 2016
7727a68
Improve messages on successfully subscribing/unsubscribing to/from st…
aglasgall Nov 20, 2016
6ee496b
Initial support for displaying message edits
aglasgall Nov 20, 2016
efb0807
update README
aglasgall Nov 20, 2016
c753a6a
further README updates
aglasgall Nov 20, 2016
cc6de81
untabify files and add file-local variables to keep them that way. Th…
aglasgall Nov 20, 2016
ca7ab9d
initial implementation of presence
aglasgall Nov 20, 2016
6607b83
Fix whitespace in Message/Zulip.pm
dehnert Nov 20, 2016
9ec88c6
Zulip: warn about lack of SSL in an admin message
dehnert Nov 20, 2016
05b1ab8
Zulip: Better private reply support
dehnert Nov 20, 2016
7c6a07f
reset presence interval to 60s now that it works
aglasgall Nov 20, 2016
30eb401
smartfilter part 1: personal threads
aglasgall Nov 20, 2016
a93ff35
smartfilter part 2: class messages
aglasgall Nov 21, 2016
2776966
Add zulip:getsubs to list current subscriptions
aglasgall Nov 21, 2016
51ce84b
grody but functional smartfilter support for names with spaces
aglasgall Nov 21, 2016
ac53f3d
giant README update
aglasgall Nov 21, 2016
8c77c4f
more README
aglasgall Nov 21, 2016
eda7d62
Don't try to register for events if zulip is not configured (e.g. if …
aglasgall Nov 22, 2016
6226f0e
more README updates
aglasgall Nov 22, 2016
20fb602
Actually build zulip module as part of build
aglasgall Oct 16, 2017
e5f5e2c
Make -c and -s options to zulip:write required
aglasgall Oct 16, 2017
f0bd871
add missing Makefile.PL
aglasgall Oct 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion perl/lib/BarnOwl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ our @EXPORT_OK = qw(command getcurmsg getnumcols getnumlines getidletime
register_idle_watcher unregister_idle_watcher
zephyr_getsender zephyr_getrealm zephyr_zwrite
zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs
queue_message admin_message
queue_message get_message_by_id admin_message
start_edit
start_question start_password start_edit_win
get_data_dir get_config_dir popless_text popless_ztext
Expand Down
36 changes: 20 additions & 16 deletions perl/lib/BarnOwl/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ sub serialize {
my ($this) = @_;
my $s;
for my $f (keys %$this) {
my $val = $this->{$f};
if (ref($val) eq "ARRAY") {
for my $i (0..@$val-1) {
my $aval;
$aval = $val->[$i];
$aval =~ s/\n/\n$f.$i: /g;
$s .= "$f.$i: $aval\n";
}
} else {
$val =~ s/\n/\n$f: /g;
$s .= "$f: $val\n";
}
my $val = $this->{$f};
if (ref($val) eq "ARRAY") {
for my $i (0..@$val-1) {
my $aval;
$aval = $val->[$i];
$aval =~ s/\n/\n$f.$i: /g;
$s .= "$f.$i: $aval\n";
}
} else {
$val =~ s/\n/\n$f: /g;
$s .= "$f: $val\n";
}
}
return $s;
}
Expand Down Expand Up @@ -303,11 +303,11 @@ sub legacy_populate_global {
$BarnOwl::login = $m->login ;
$BarnOwl::auth = $m->auth ;
if ($m->fields) {
@BarnOwl::fields = @{$m->fields};
@main::fields = @{$m->fields};
@BarnOwl::fields = @{$m->fields};
@main::fields = @{$m->fields};
} else {
@BarnOwl::fields = undef;
@main::fields = undef;
@BarnOwl::fields = undef;
@main::fields = undef;
}
}

Expand All @@ -330,3 +330,7 @@ sub subcontext {""}


1;

# Local Variables:
# indent-tabs-mode: nil
# End:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a whitespace-only change.

2 changes: 1 addition & 1 deletion perl/modules/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MODULES = Jabber IRC WordWrap Twitter Facebook Kerberos
MODULES = Jabber IRC WordWrap Twitter Facebook Kerberos Zulip

EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib)
EXTRA_DIST += \
Expand Down
15 changes: 15 additions & 0 deletions perl/modules/Zulip/Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use strict;
use warnings;

use inc::Module::Install;

requires('AnyEvent::HTTP');
requires('AnyEvent::TLS');
requires('JSON');
requires('URI');
requires('URI::Encode');
requires('MIME::Base64');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These requirements should be documented in the top-level README.


barnowl_module('Zulip');

WriteAll;
134 changes: 134 additions & 0 deletions perl/modules/Zulip/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
-*- text -*-

BarnOwl::Module::Zulip is a terminal client for the Zulip
(https://zulip.org/) chat system. Zulip is influenced heavily by
Zephyr and so BarnOwl is a pretty good match for it.


PREREQUISITES

- all the normal BarnOwl dependencies, including PAR and AnyEvent::HTTP

- URI::Encode


SETUP

You'll need to get your personal API key from Zulip. You can find this
on your "settings" page.

To use BarnOwl::Module::Zulip, create a file called "zulip" in
~/.owl. The contents of this file should be a JSON dictionary:

{ "user": <the email address you use to log into Zulip>,
"apikey": <your personal API key>,
"api_url": <the API URL root for your Zulip instance. Should look something like 'https://chat.zulip.org/api/v1'. MUST NOT have a trailing / right now>,
"default_realm": <optionally, the domain name you expect most users on your realm to have usernames under. Convenience feature for letting you send personals with less typing>
}

If your Zulip instance uses HTTPS (as it should), it is optional (but *HIGHLY RECOMMENDED*) to specify an additional set of options in the dictionary:

{ "user": <same as before>,
...
"ssl": {
"ca_file": <path to your system's list of trusted root SSL certificates. It's /etc/ssl/certs/ca-certificates.crt on Ubuntu or Debian>
}
}

If your Zulip instance requires SSL client credentials, specify the
paths to the certificate and key as "cert_file" and "key_file",
respectively, under "ssl".


USAGE

When you start BarnOwl, you should run "zulip:login". Or put it at the
end of ~/.owl/startup.


FEATURES:

- sending and receiving zulip stream and personal messages (including
with multiple recipients, mostly-functionally)

- listing, adding, and removing subscriptions

- minimal support for stream creation (if you try to sub to a stream
that doesn't exist, it'll _probably_ create a new one with whatever
your site's default settings are)

- full filter language support (message attributes are mostly the same
as zephyr) including support for "punt" and mostly-functional
smartfilter.

- support for displaying message edits (they show up as new messages
with the correct stream/topic/sender with the new text and opcode
EDIT)


MISSING/UNFINISHED FEATURES:

- backfilling from history (this will be hard. barnowl currently only
supports appending to the msglist from perl, and I think the msglist
is also an array, so that's potential badness)

- smartnarrow robustness (has been ported from C, but almost certainly
still has weird corner cass)

- better handling of personals with multiple recipients (I think Alex
implemented this, but more testing is never bad)

- syncing the curmsg pointer with the server

- sending presence more cleverly (right now it just sends a ping every
minute regardless of how active you are)

- deleting messages is probably interestingly broken right now w/r/t
the hash of zid -> barnowl message id. make it work.

- being able to view user presence (ala zlocate/aim buddy list/jabber
roster/etc)

- being able to invite people to invite-only streams

- improved URL generation. We shouldn't have to warn people not to
have a trailing / in their api_url setting.


FEATURES THAT SHOULD PROBABLY EXIST BUT THAT I DON'T REALLY CARE ABOUT
MUCH

- editing messages

- option to allow in-place update of edited messages instead of adding
a new message

- being able to create a stream with options (e.g. invite-only) set

- being able to edit attributes of streams (zephyr doesn't have 'em,
but zulip does)

- being able to delete streams

- being able to see a list of people subscribed to a given stream


FEATURES THAT WOULD BE HILARIOUS

- zcrypt support


OTHER DEVELOPMENT WORK:

- general robustness (e.g. if you try to zulip:login again after
do_poll has given up (because the server went away and didn't come
back in a reasonable time, it probably crashes hard.)

- code cleanup (kill globals with fire, refactor long functions,
possibly break out some modules?)

- Probably break out AnyEvent::Zulip into a separate module that this
just uses

- get this merged into barnowl mainline, especially now that it has an
XS change (i.e. it's not just a drop-in PAR anymore)
Loading