Commit Graph

418 Commits

Author SHA1 Message Date
Steve Howell 51db22c86c per-request caches: Add per_request_cache library.
We have historically cached two types of values
on a per-request basis inside of memory:

    * linkifiers
    * display recipients

Both of these caches were hand-written, and they
both actually cache values that are also in memcached,
so the per-request cache essentially only saves us
from a few memcached hits.

I think the linkifier per-request cache is a necessary
evil. It's an important part of message rendering, and
it's not super easy to structure the code to just get
a single value up front and pass it down the stack.

I'm not so sure we even need the display recipient
per-request cache any more, as we are generally pretty
smart now about hydrating recipient data in terms of
how the code is organized. But I haven't done thorough
research on that hypotheseis.

Fortunately, it's not rocket science to just write
a glorified memoize decorator and tie it into key
places in the code:

    * middleware
    * tests (e.g. asserting db counts)
    * queue processors

That's what I did in this commit.

This commit definitely reduces the amount of code
to maintain. I think it also gets us closer to
possibly phasing out this whole technique, but that
effort is beyond the scope of this PR. We could
add some instrumentation to the decorator to see
how often we get a non-trivial number of saved
round trips to memcached.

Note that when we flush linkifiers, we just use
a big hammer and flush the entire per-request
cache for linkifiers, since there is only ever
one realm in the cache.
2023-08-11 11:09:34 -07:00
Steve Howell 031e3ae3f0 caching docs: Tweak a few things.
Some claims seemed a little exaggerated or overly
precise.
2023-08-11 10:57:42 -07:00
Sahil Batra c843600d76 docs: Fix get_user function in caching documentation.
This commit fixes the get_user function code to be same
as that of the original function in models.py.
2023-08-10 17:35:43 -07:00
Anders Kaseorg b285813beb error_notify: Remove custom email error reporting handler.
Restore the default django.utils.log.AdminEmailHandler when
ERROR_REPORTING is enabled.  Those with more sophisticated needs can
turn it off and use Sentry or a Sentry-compatible system.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-20 11:00:09 -07:00
Anders Kaseorg 052984bc14 utils: Remove make_safe_digest wrapper.
It’s unclear what was supposed to be “safe” about this wrapper.  The
hashlib API is fine without it, and we don’t want to encourage further
use of SHA-1.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-07-19 10:54:05 -07:00
David Rosa 513eb510aa docs: Rename "private message" -> "direct message".
- Updates instances of "private message", "PM", and "private_message",
  excluding historical references in `overview/changelog.md`.
- Also excludes `/docs/translating` since we would need new
  translations for "direct messages" and "DMs".
2023-06-23 14:36:16 -07:00
Anders Kaseorg 639efc5ce1 docs: Update Transifex URLs.
https://help.transifex.com/en/articles/7171815-web-application-s-domain-change

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-06-12 17:38:41 -07:00
Tim Abbott 5e5d151c0c docs: Tweak a few details on the release checklist. 2023-06-07 12:48:25 -07:00
Alex Vandiver 54590e67f2 docs: Fix link to sentry deploy hook. 2023-05-30 11:25:43 -07:00
Anders Kaseorg dc158b18f2 release-checklist: Purge unneeded beta branch.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-05-29 18:07:54 -07:00
Karl Stolley 04656bf16f docs: Provide an example of dynamic styling. 2023-05-24 12:31:11 -07:00
Karl Stolley fe1b7a9bb3 docs: Integrate HTML and CSS style with subsystem doc. 2023-05-24 12:31:11 -07:00
Karl Stolley 735618b9db docs: Restructure CSS introduction.
This better presents the CSS organization for readers, and also
removes a stale reference and link to Bootstrap.

Because postcss-nesting's spec-aligned syntax has tripped up some
contributors, the mention of PostCSS now includes a link to the
postcss-nesting README and the CSS Nesting spec from the W3C, which
PostCSS Nesting attempts to adhere to.
2023-05-24 12:31:11 -07:00
Karl Stolley 3fd621b608 docs: Correct stale Chrome and Handlebars links. 2023-05-24 12:31:11 -07:00
Alex Vandiver 68722e7d3c release-checklist: Add a mastodon announce step. 2023-05-19 16:55:30 -07:00
Alex Vandiver 68c37c9d7b release-checklist: Adjust for the blogs being in Astro. 2023-05-19 16:55:30 -07:00
Alex Vandiver 510b96046a docs: Update production docs for local S3 caching. 2023-05-01 11:28:08 -07:00
AcKindle3 4544eb4576 email: Replace `uri` with `url` in templates and backend.
In #23380 we want to change all ocurrences of `uri` to `url`. This
commit changes the ocurrences of `uri` appeared in files related to
email, including templates (`.html`, `.txt`) and backend (`.py`)
codes.

In `email.md`, `base_images_uri` is changed to `images_base_url` -
the words `base` and `images` are swapped and plural form is added
for `image`.  This is becasue the former is not found anywhere in
the codebase while the later appears a lot. To reduce confusion,
this doccumentation changed accordingly.
2023-04-26 16:37:16 -07:00
Alex Vandiver 2d5c678614 blueslip: Only show in dev mode, or report to Sentry.
This removes the production reporting to `/json/report/error` upon
`blueslip.error`, and replaces it with reporting to Sentry, if
enabled.  Sentry provides better reporting and grouping for exceptions
than the email- and `#errors`-reporting provided by the
`/json/report/error` endpoint.

The development behaviour of rendering `blueslip.error` messages and
stacktraces immediately, and stopping execution, is preserved.

To better chain exception information, the whole previous exception is
passed to `blueslip.error`, not just the stack, and the second
parameter is formalized to be an object to map to Sentry's "context"
concept.
2023-04-13 14:59:58 -07:00
Alex Vandiver f9f7c7b114 docs: Document Sentry frontend reporting. 2023-04-13 14:59:58 -07:00
Daniil Fadeev 2f203f4de1 emails: Inline CSS in emails in build_email.
Previously, we had an architecture where CSS inlining for emails was
done at provision time in inline_email_css.py. This was necessary
because the library we were using for this, Premailer, was extremely
slow, and doing the inlining for every outgoing email would have been
prohibitively expensive.

Now that we've migrated to a more modern library that inlines the
small amount of CSS we have into emails nearly instantly, we are able
to remove the complex architecture built to work around Premailer
being slow and just do the CSS inlining as the final step in sending
each individual email.

This has several significant benefits:

* Removes a fiddly provisioning step that made the edit/refresh cycle
  for modifying email templates confusing; there's no longer a CSS
  inlining step that, if you forget to do it, results in your testing a
  stale variant of the email templates.
* Fixes internationalization problems related to translators working
  with pre-CSS-inlined emails, and then Django trying to apply the
  translators to the post-CSS-inlined version.
* Makes the send_custom_email pipeline simpler and easier to improve.

Signed-off-by: Daniil Fadeev <fadeevd@zulip.com>
2023-04-05 12:22:29 -07:00
Daniil Fadeev 5c6f842b28 emails: Replace Premailer with CSS-inline.
Primary goal of library replacement is improving execution speed.
This commit should not affect the functionality of the system
or make any changes to it.
2023-04-03 15:15:05 -07:00
Anders Kaseorg 3a27b12a7d dependencies: Switch to pnpm.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-20 15:48:29 -07:00
sbansal1999 9e4529c48b docs: Change extensions from .js to .ts for some filenames.
Since we are migrating from JavaScript to TypeScript
some files in the documentation are still with their
old extension. This commit changes those file extensions.
2023-03-12 15:17:53 -07:00
Anders Kaseorg c382904638 docs: Remove bad advice about pinning versions.
Because `yarn.lock` includes transitive dependencies, it already pins
our dependencies more comprehensively than `package.json` would if we
followed this bad advice, which we don’t, as of commit
9b0401b76d (#13118).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-05 21:26:55 -08:00
Anders Kaseorg 43b4f10578 run-dev: Drop .py from script name.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-03-03 18:02:37 -08:00
Lakshay Mittal 9be35d2447
docs: Fix outdated description of where stats views are. 2023-03-02 13:38:08 -08:00
Anders Kaseorg 0ef8e88b17 webpack: Move webpack configuration to web.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-24 06:35:58 -08:00
Anders Kaseorg cea1119423 node_tests: Move to web/tests.
This lets us simplify the long-ish ‘../../static/js’ paths, and will
remove the need for the ‘zrequire’ wrapper.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 16:04:17 -08:00
Anders Kaseorg c1675913a2 web: Move web app to ‘web’ directory.
Ever since we started bundling the app with webpack, there’s been less
and less overlap between our ‘static’ directory (files belonging to
the frontend app) and Django’s interpretation of the ‘static’
directory (files served directly to the web).

Split the app out to its own ‘web’ directory outside of ‘static’, and
remove all the custom collectstatic --ignore rules.  This makes it
much clearer what’s actually being served to the web, and what’s being
bundled by webpack.  It also shrinks the release tarball by 3%.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 16:04:17 -08:00
Alex Vandiver 3109d40b21 puppet: Add a sentry release class.
This installs the Sentry CLI, and uses it to send API events to Sentry
when a release is started and completed.
2023-02-10 15:53:10 -08:00
Alex Vandiver bcd190ecf2 docs: Document backend Sentry error logging. 2023-02-10 15:53:10 -08:00
Anders Kaseorg ec58b6790d install-node: Upgrade Node.js to 18.14.0; manage Yarn with Corepack.
Corepack manages multiple per-project version of Yarn and PNPM, which
means we have to maintain less installation code, and could help us
switch away from Yarn 1 without making the system unusable for
development of other Yarn 1 projects.

https://nodejs.org/api/corepack.html

The Unicode spaces in the timerender test resulted from an ICU
upgrade: https://github.com/nodejs/node/pull/45068.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-09 15:50:47 -08:00
David Rosa 08e9686cd2 contributor docs: Rename "Upgrade or modify Zulip" -> "Upgrade Zulip".
Fixes part of #23984.
2023-01-27 12:41:56 -08:00
Anders Kaseorg bd884c88ed Fix typos caught by typos.
https://github.com/crate-ci/typos

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-03 11:09:50 -08:00
David Rosa 4ad47fd550 docs: Rename "operators" to "filters".
Changes all the uses of the word "operators" to "filters" in
contributor docs, help center, and landing page to align with
the updated help center documentation.
2022-12-09 13:52:13 -08:00
Anders Kaseorg 92251a7cf6 release-checklist: Update blog post checklist for Astro.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-12-07 17:41:21 -08:00
Alex Vandiver 2c2afddf1e release-checklist: Clarify main changes are one commit, not two. 2022-11-16 14:37:07 -08:00
Alex Vandiver dd8ff7e22b release-checklist: Remove duplicated words.
A classic "I love paris in the the springtime" bug.
2022-11-16 14:37:07 -08:00
Alex Vandiver 6be6bcc5e3 release-checklist: Update and clarify the Docker / Helm steps. 2022-11-16 14:37:07 -08:00
Alex Vandiver fac4c38404 release-checklist: Note that we can test on 22.04 as well. 2022-11-16 14:37:07 -08:00
Mateusz Mandera d02b1f0ae6 docs: Move OPEN_REALM_CREATION doc section to multiple-organizations.md.
Since this is being moved to admin-facing documentation, also adds a
paragraph about the main concern with enabling this on a server that's
not zulip.com.
2022-10-31 17:56:45 -07:00
Zixuan James Li ca922919f4 docs: Document handling noop migrations.
Inspired by #23377. We document a convention maneuver to avoid adding
noop migrations, which involves modifying the latest migration related
to the fields in question.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-10-31 14:15:00 -07:00
evykassirer c321f57785 settings: Explain that Google blob emojis are deprecated.
Part of fixing #19371.
2022-10-04 12:29:35 -07:00
Zixuan James Li 44df15e19b docs: Remove legacy references to "topic" as "subject".
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-10-04 11:59:23 -07:00
Zixuan James Li ae33873902 docs: Update documentation for secrets related settings.
This is a follow-up to #22699 to document the new `get_mandatory_secret`
helper.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-08-25 14:50:41 -07:00
David Rosa 5cac44be06 docs: Reorganize sections and pages about contributing to Zulip.
We should rearrange Zulip's developer docs to make it easier to
find the documentation that new contributors need.

Name changes
Rename "Code contribution guide" section -> "Contributing to Zulip".
Rename "Contributing to Zulip" page -> "Contributing guide".

Organizational changes to the newly-named "Contributing to Zulip":
Move up "Contributing to Zulip", as the third link in sidebar index.
Move up renamed "Contributing guide" page to the top of this section.
Move up "Zulip code of Conduct", as the second link of this section.
Move down "Licensing", as the last link of this section.
Move "Accessibility" just below "HTML and CSS" in Subsystems section.

Update all links according to the changes above.
Redirects should be added as needed.

Fixes: #22517.
2022-08-25 11:24:57 -07:00
Tim Abbott 8d49769d2e docs: Improve documentation for development environment subdomains. 2022-07-25 17:05:18 -07:00
Noble Mittal 76bff6e1ac
docs: Fix typo in hashchange-system.md.
Fixes a missing close parenthesis.
2022-07-22 11:15:16 -07:00
Anders Kaseorg 412e90f601 provision: Avoid distutils; keep PROVISION_VERSION as a tuple.
distutils is deprecated in Python 3.10 and will be removed in Python
3.12.  We don’t need a full-powered version parser for this anyway.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-07-20 22:03:30 -07:00