zulip/zerver/lib
Tim Abbott c57c4cf703 notifications: Fix push notifications with multiple realms.
Previously, Zulip did not correctly handle the case of a mobile device
being registered with a push device token being registered for
multiple accounts on the same server (which is a common case on
zulipchat.com).  This was because our database `unique` and
`unique_together` indexes incorrectly enforced the token being unique
on a given server, rather than unique for a given user_id.

We fix this gap, and at the same time remove unnecessary (and
incorrectly racey) logic deleting and recreating the tokens in the
appropriate tables.

There's still an open mobile app bug causing repeated re-registrations
in a loop, but this should fix the fact that the relevant mobile bug
causes the server to 500.

Follow-up work that may be of value includes:
* Removing `ios_app_id`, which may not have much purpose.
* Renaming `last_updated` to `data_created`, since that's what it is now.

But none of those are critical to solving the actual bug here.

Fixes #8841.
2018-10-10 16:15:52 -07:00
..
bugdown user docs: Add import-from-hipchat. 2018-10-09 15:23:07 -07:00
url_preview url_preview: Don't import beautifulsoup at import time. 2018-08-08 14:19:42 -07:00
webhooks webhooks/gitlab: Include title in Issue Hook event messages. 2018-07-14 09:38:11 +05:30
__init__.py
actions.py notifications: Fix soft-deactivated users don't get push notifications. 2018-09-21 12:06:18 -07:00
addressee.py address: Remove dead msg_type function. 2018-05-13 17:47:21 -07:00
alert_words.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
api_test_helpers.py api docs: Document GET /users/<email>/presence. 2018-08-31 15:15:54 -07:00
attachments.py zerver/lib: Use python 3 syntax for typing. 2017-11-21 20:56:40 -08:00
avatar.py mypy: Enable strict optional in lib/avatar.py. 2018-05-17 11:11:55 -07:00
avatar_hash.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
bot_config.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
bot_lib.py embedded bots: Use get_active_user helper to look up users. 2018-05-20 20:04:16 -07:00
bot_storage.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
bulk_create.py models: Add USER_CREATED event type constant to RealmAuditLog. 2018-07-10 15:42:26 +05:30
cache.py users: Get all API keys via wrapper method. 2018-08-08 16:35:17 -07:00
cache_helpers.py users: Get all API keys via wrapper method. 2018-08-08 16:35:17 -07:00
camo.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
ccache.py str_utils: Move force_bytes into ccache.py. 2018-05-15 19:07:32 -07:00
context_managers.py zerver/lib: Use python 3 syntax for typing. 2017-11-21 20:45:52 -08:00
create_user.py utils: Move random API key generator as generate_api_key. 2018-08-08 16:45:25 -07:00
db.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
debug.py mypy: Set local_partial_types = True. 2018-05-21 22:41:00 -07:00
digest.py models: Rename Realm.show_digest_email field. 2018-08-01 11:05:58 -07:00
domains.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
email_mirror.py email_mirror: Limit message length using defined constants. 2018-09-21 10:39:57 -07:00
emoji.py emoji: Move `EMOTICON_CONVERSIONS` mapping to build_emoji infra. 2018-07-23 12:35:08 -07:00
error_notify.py bugdown: Improve exception handler for BugdownRenderingException. 2018-07-26 09:27:55 -07:00
events.py events: Query starred message ids in fetch_initial_state_data. 2018-08-21 13:01:41 -07:00
exceptions.py Remove `code` from JsonableError.__init__. 2018-08-22 16:51:40 -07:00
export.py export: Fix exporting files with S3 upload backend. 2018-09-20 20:14:19 -07:00
feedback.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
fix_unreads.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
generate_test_data.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
hotspots.py signup: Copy hotspots when importing settings. 2018-06-16 08:50:49 -07:00
html_diff.py mypy: Remove type: ignores that are unnecessary with new mypy. 2017-11-25 10:06:28 -08:00
i18n.py i18n: Pass translation data in page_params. 2018-05-30 08:57:26 -07:00
import_realm.py import: Speed up create_subscription_events(). 2018-10-02 16:55:16 -07:00
initial_password.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
integrations.py webhooks: Add Netlify integration. 2018-10-05 17:04:40 -07:00
json_encoder_for_html.py mypy: Fix annotations for json_encoder_for_html. 2017-11-22 01:32:46 -08:00
logging_util.py settings: Fix double negative in LOGGING_NOT_DISABLED. 2018-03-21 18:03:05 -07:00
management.py management commands: Add sleep_forever to lib/management. 2018-08-17 09:20:51 -07:00
mdiff.py mypy: Amend diff_strings to return str or raise DiffException. 2018-02-13 11:40:51 -08:00
mention.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
message.py message flags: Add where_starred helper and use it. 2018-08-21 15:28:04 -07:00
migrate.py migrate: Add do_batch_update method for running batch updates. 2018-05-31 13:00:34 -07:00
mobile_auth_otp.py mobile: Make otp_encrypt_api_key accept API keys. 2018-08-08 16:45:40 -07:00
name_restrictions.py signup: Add opayq.com to disposable domain whitelist. 2018-08-13 10:56:47 -07:00
narrow.py narrow: Add is_web_public_compatible check for narrows. 2018-05-21 08:45:48 -07:00
notifications.py logging: Show timestamp in UTC in non-django production scripts. 2018-08-20 12:52:40 -07:00
onboarding.py create_realm_internal_bots: Refactor to extract main op as a function. 2018-05-23 11:53:22 +05:30
openapi.py Minimize race conditions for reading zulip.yaml. 2018-09-12 11:07:20 -07:00
outgoing_webhook.py Allow "content" from outgoing webhooks. 2018-10-09 15:56:24 -07:00
parallel.py zerver/lib: Use python 3 syntax for typing. 2017-11-18 16:09:04 -08:00
profile.py mypy: Improve typing to profile.py & remove FuncT from decorator.py. 2017-10-29 17:10:13 -07:00
push_notifications.py notifications: Fix push notifications with multiple realms. 2018-10-10 16:15:52 -07:00
queue.py mypy: Remove some now-unnecessary type: ignores. 2018-03-28 10:39:05 -07:00
rate_limiter.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
realm_icon.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
redis_utils.py zerver/lib: Use python 3 syntax for typing. 2017-11-18 16:09:04 -08:00
request.py request: Add new str_validator validator type. 2018-05-03 21:11:02 -07:00
request.pyi request.pyi: Remove unused import of typing.Text. 2018-05-14 05:16:22 +05:30
response.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
rest.py uploads: Add new way of querying for mobile uploads endpoint. 2018-04-13 17:51:45 -07:00
retention.py zerver/lib: Use python 3 syntax for typing. 2017-11-28 17:15:14 -08:00
send_email.py models: Create delivery_email field in userprofile. 2018-07-12 12:30:20 +05:30
sessions.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
soft_deactivation.py models: Add USER_SOFT_DEACTIVATED event type constant to RealmAuditLog. 2018-07-10 15:42:26 +05:30
sqlalchemy_utils.py mypy: Set local_partial_types = True. 2018-05-21 22:41:00 -07:00
statistics.py zerver/lib: Use Python 3 syntax for typing for several files. 2017-11-28 17:02:24 -08:00
storage.py storage: Fix hash-renaming of various non-CSS/JS file types. 2018-07-24 09:42:25 -07:00
str_utils.py models: Remove unused ModelReprMixin class. 2018-05-15 19:11:22 -07:00
stream_recipient.py zerver/lib: Use python 3 syntax for typing. 2017-11-18 16:09:04 -08:00
stream_subscription.py Mypy: Use models.py QuerySet annotation approach in stream_subscription.py. 2018-03-15 12:54:43 -07:00
stream_topic.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
streams.py default stream: Allows admins to remove any default stream. 2018-08-07 13:28:30 -07:00
subdomains.py Enable pycodestyle W605 (invalid escape sequence). 2018-07-03 16:54:46 +02:00
test_classes.py tests: Move clear_client_event_queues_for_testing to ZulipTestCase. 2018-08-10 13:58:39 -07:00
test_data.source.txt test_data.source.txt: Replace postmodernism generator text with a play. 2017-08-23 13:00:39 -07:00
test_fixtures.py test_fixtures: Fix bug with run_db_migrations for test platform. 2018-07-09 14:17:53 +05:30
test_helpers.py bulk_remove_subscriptions: Pass client object in. 2018-08-01 16:48:31 -07:00
test_runner.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
tex.py Enable pycodestyle W605 (invalid escape sequence). 2018-07-03 16:54:46 +02:00
thumbnail.py thumbnails: Fix bug with '/user_avatar/' links in Zulip messages. 2018-08-10 17:17:50 -07:00
timeout.py mypy: Add assertion in timeout.py. 2018-04-25 08:58:55 -07:00
timestamp.py zerver/lib: Use python 3 syntax for typing. 2017-11-18 16:09:04 -08:00
timezone.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
topic_mutes.py zerver/lib: Change use of typing.Text to str. 2018-05-12 15:22:39 -07:00
type_debug.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
types.py zerver/models.py: Modify FIELD_TYPE_DATA, add keyword for field type. 2018-08-21 11:37:51 -07:00
unminify.py unminify: Clean up unnecessary repetition of webpack:/// URLs. 2018-08-03 15:56:40 -07:00
upload.py emoji: Add support for animated GIF images. 2018-08-04 11:46:58 -07:00
url_encoding.py notifications: Extract zerver/lib/url_encoding.py. 2018-07-28 15:12:55 -07:00
user_agent.py tests: Move zerver/fixtures to zerver/tests/fixtures for clarity. 2018-04-19 21:50:17 -07:00
user_groups.py zerver/lib: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
users.py users: Get all API keys via wrapper method. 2018-08-08 16:35:17 -07:00
utils.py utils: Move random API key generator as generate_api_key. 2018-08-08 16:45:25 -07:00
validator.py requirements: Upgrade pyflakes to 2.0.0. 2018-05-24 11:31:36 -07:00
widget.py tests: Test get_widget_data() helper. 2018-08-24 10:00:25 -07:00
zcommand.py zcommand: Fix broken switch mode message. 2018-08-08 11:29:49 -07:00
zephyr.py Extract a zephyr.py library. 2018-08-11 14:51:26 -07:00