Commit Graph

27 Commits

Author SHA1 Message Date
Steve Howell ee00d848b9 refactor: Eliminate use of page_params.fullname.
We now use people.my_full_name().
2017-01-21 21:45:12 -08:00
Steve Howell 53308b49b2 refactor: Remove last uses of page_params.email in JS code.
Earlier commits removed all uses of page_params.email outside
of people.js, and it turns out we have page_params.user_id, so
we don't even need page_params.email for seeding the data.
2017-01-21 21:45:12 -08:00
Steve Howell 5bce806c4e refactor: Introduce people.my_current_email().
This commit doesn't change any behavior yet, but it starts us
down the road of deprecating page_params.email and allowing
people.js to control all access to the current user's email,
which will be important for email changes.
2017-01-21 21:45:12 -08:00
Steve Howell d757f840dd Make nicer slugs for "pm-with" narrows.
The slugs for PM-with narrows now have user ids in them, so they
are more resilient to email changes, and they have less escaping
characters and are generally prettier.

Examples:

    narrow/pm-with/3-cordelia
    narrow/pm-with/3,5-group

The part of the URL that is actionable is the comma-delimited
list of one or more userids.

When we decode the slugs, we only use the part before the dash; the
stuff after the dash is just for humans.  If we don't see a number
before the dash, we fall back to the old decoding (which should only
matter during a transition period where folks may have old links).

For group PMS, we always say "group" after the dash. For single PMs,
we use the person's email userid, since it's usually fairly concise
and not noisy for a URL.  We may tinker with this later.

Basically, the heart of this change is these two new methods:

    people.emails_to_slug
    people.slug_to_emails

And then we unify the encode codepath as follows:

    narrow.pm_with_uri ->
    hashchange.operators_to_hash ->
    hashchange.encode_operand ->
    people.emails_to_slug

The decode path didn't really require much modication in this commit,
other than to have hashchange.decode_operand call people.slug_to_emails
for the pm-with case.
2017-01-17 15:13:49 -08:00
Tim Abbott 9ff8c9e358 subs: Access users by ID in new stream creation. 2017-01-06 23:18:53 -08:00
Steve Howell ef893dc8dd Live-update user list for name changes.
When somebody changes their name, we will now update
the buddy list right away.  The old code was trying
to do this through a code path that was designed for
true presence updates, but it was also passing in an
empty array, instead of undefined, which caused it to
fail to invoke the intended part of the codepath to
redraw the buddy list.

Now we just call the new activity.redraw() function,
which does the right thing for the buddy list.

The group PM list was live-updating before this change,
and it continues to live-update as part of the new
activity.redraw() function.
2017-01-04 19:45:15 -08:00
Steve Howell b46d7654f8 Change people.remove() to people.deactivate() and fix bug.
This commit changes people.remove() to be people.deactivate(),
and it fixes a bug where deactivating users was causing tracebacks
in the PM list if somebody had PM'ed the deactivated user
recently.
2016-12-15 17:44:58 -08:00
Steve Howell b2bb2f8ea0 Extract people.init() function.
We need this for node tests, so that you don't have to explicitly
remove every user between tests.  (Also, people.remove() is about
to have different semantics.)
2016-12-15 17:44:58 -08:00
Rafid Aslam 45f39be37f lint: Fix many no-unused-vars eslint rule violations.
These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
2016-12-14 21:34:51 -08:00
Tim Abbott 459421d045 eslint: Update node tests to use new comma-dangle rules.
* In most cases, eslint --fix with the right comma-dangle settings was
  able to update the code correctly.

* The exceptions were cases where the parser incorrectly treated the
  arguments to functions like `assert_equal` as arguments; we fixed
  these manually.  Since this is test code, we can be reasonably
  confident that just fixing the failures suffices to correct any bugs
  introduced by making changes automatically.
2016-12-03 15:00:24 -08:00
Steve Howell d953eca14c Make group PMs reply-to's more consistent in case.
We now sort lists of users ids deterministically, and we also
sort list of emails deterministically and without regard to case.

This probably fixes the bug #2343, although I never got a great
repro on that.
2016-11-26 11:48:52 -08:00
Steve Howell 1783879108 people.js: Add methods for user_ids_string/emails_string.
Added:
    * people.user_ids_string_to_emails_string
    * people.emails_strings_to_user_ids_string
2016-11-15 18:31:59 -08:00
Steve Howell 71d93207cd Match "Charles Dickens" with "ch di" in subscriber search. 2016-11-14 16:01:13 -08:00
Steve Howell 2746518f3c Make subscriber filter match on emails.
We will match emails that start with search terms.
2016-11-14 16:01:13 -08:00
Steve Howell 504045f47d Pass in search terms as arrays to test_filtered_users(). 2016-11-14 16:01:13 -08:00
Steve Howell e1372ddf5d Add people.get_user_id(). 2016-11-04 11:30:18 -07:00
Steve Howell 4cd39010d1 Add people.get_person_from_user_id().
This requires the introduction of people_by_user_id_dict
and changes to people.add() and people.remove().
2016-11-04 11:30:18 -07:00
Steve Howell 9b97b5da13 Improve test coverage for people.get_recipient_count(). 2016-11-04 10:05:11 -07:00
Steve Howell 30e01306d9 Eliminate people.reify() and mostly ignore unknown users.
If I try to send a message to an unknown user (which is possible
for some types of realms), then I simply ignore them during the
send codepath, so that I don't later need to patch up their attributes.
2016-11-03 16:20:45 -07:00
Steve Howell 15d44f8d71 Encapsulate pm_recipient_count.
We no longer store pm_recipient_count on person objects, but we
instead use a Dict to store them.  Then the new API is this:

    people.get_recipient_count()
    people.incr_recipient_count()
2016-11-03 16:20:45 -07:00
Steve Howell 2d945d7296 Add people.get_realm_persons(). 2016-11-01 13:55:48 -07:00
Steve Howell aa07b32d58 Add people.get_all_persons(). 2016-11-01 13:55:48 -07:00
sonali0901 1bc7990327 Extract people.filter_people_by_search_terms()
This code used to be in subs.js, but now it's in people.js and has
some unit tests.

I did this w/showell as part of live coding on Zulip.
2016-10-20 21:44:26 -07:00
Steve Howell ebe76dd2c3 Add stub_out_jquery() for node tests. 2016-07-30 14:54:30 -07:00
Steve Howell 6ce8f3da6d Fix node tests to be able to run standalone.
These tests would work as part of the whole suite, but
not standalone, because they were getting objects out
of node's require cache that a previous test had cleaned up.

Now they should work standalone as well, and the tests
are more explicit about their dependencies.
2016-07-30 14:54:30 -07:00
Tim Abbott b25562ca1d Add and use util.is_current_user helper function.
Previously, we were checking if a particular user was the current user
in dozens of places in the codebase, and correct case-insensitive
checks were not used consistently, leading to bugs like #502.
2016-06-07 21:58:44 -07:00
Tim Abbott 10657c1d53 Move node tests to node_tests/. 2015-10-28 10:11:47 -07:00