Commit graph

259 commits

Author SHA1 Message Date
Hongbo Wu
0b0b521fab use generic method for uploading 2022-04-13 22:21:20 +08:00
Hongbo Wu
a806f55233 upload highlight to gcs 2022-04-13 21:18:58 +08:00
Hongbo Wu
8ba1be456c fix sanitizer invalid name 2022-04-13 13:23:21 +08:00
Hongbo Wu
3b831fecb8 test both max length and pattern if declared 2022-04-13 12:20:41 +08:00
Hongbo Wu
928ddd69a9 validate color input in label as rgb hex value 2022-04-13 12:17:12 +08:00
Jackson Harper
782781639d Update API in test 2022-04-12 12:53:08 -07:00
Jackson Harper
73ef8fef09 Rename linkId to pageId in SetLabelsInput 2022-04-12 12:46:32 -07:00
Jackson Harper
d05f091876 Add debug logging for GQL errors 2022-04-12 12:23:55 -07:00
Jackson Harper
6c5e88cf12
Merge pull request #405 from omnivore-app/feature/label-max-length
Set label name max length = 64 char
2022-04-12 11:14:20 -07:00
Jackson Harper
035b61665d
Merge pull request #376 from omnivore-app/dependabot/npm_and_yarn/googleapis-100.0.0
Bump googleapis from 59.0.0 to 100.0.0
2022-04-12 08:47:11 -07:00
Hongbo Wu
ae0d1dd2ee
Feature/search highlights backend (#395)
* add highlight mappings

* return highlight in resolvers

* temporarily skip highlight tests

* add test for getting highlights

* update merge highlight

* separate elastic methods

* roll back merge highlight test

* add highlight to elastic script

* update delete highlight in elastic

* migrate highlight data from postgres to elastic

* rescue not found exception when page is not found in the migration script

* exclude highlights in searching pages results

* search pages with highlights only with has:highlight query

* add search endpoint to search pages or highlights

* reduce code smell in search api

* fix rebase error

* fix tests

* add test for search highlight

* add test for new search endpoint

* add labels to search results

* update schema

* update search query

* fix update/share highlights

* fix rebase error

* fix tests

* add highlight model in elastic

* add savedAt and publishedAt date range in search query

* add sort by updated and recently read

* fix tests

* close db connection when tests are done

* test github action

* revert github action test

* fix rebase error

* add docker-compose for api-test

* remove unused env

* remove highlights with no page attached to

* allow get_articles resolver to search for query so we can merge it without web changes
2022-04-12 12:31:08 +08:00
Hongbo Wu
2ebdaba780
add generate api key api and test (#392)
* add generate api key api and test

* test if user can make api call with the api key
2022-04-12 12:11:45 +08:00
Hongbo Wu
bb665a704b make label name <= 64 char length 2022-04-12 12:08:02 +08:00
Hongbo Wu
b4420839bd
fix: fail to search by excluding labels with capital letter (#400)
* fix: fail to search by excluding labels with capital letter

* make all the excluded labels lowcased

* Revert "make all the excluded labels lowcased"

This reverts commit 866bed4080.
2022-04-11 14:05:21 +08:00
Jackson Harper
a68a5fb066 Labels are ordered by creation time in API now 2022-04-06 11:00:14 -07:00
Jackson Harper
48ca13818f Prettier fixes 2022-04-06 10:45:01 -07:00
Jackson Harper
57f865c9a2 Update to typeorm 0.3 2022-04-06 10:37:13 -07:00
Jackson Harper
26bff1b25d Pin yarn version w/volta 2022-04-06 10:06:24 -07:00
Jackson Harper
63a374b31d package syntax 2022-04-06 10:05:06 -07:00
Jackson Harper
1bac06107d Update volta version 2022-04-06 10:04:04 -07:00
Jackson Harper
1cdb7753c3 Update typeorm usage 2022-04-06 09:56:32 -07:00
Jackson Harper
06360a5993
Merge branch 'main' into OMN-190 2022-04-06 09:24:49 -07:00
Hongbo Wu
d1269f815e identify a newsletter by checking both list-url and unsubscribe-url in headers and email sender address 2022-04-06 20:59:14 +08:00
Hongbo Wu
7569e988bf
upgrade typeorm to 3.0 (#359)
* upgrade typeorm to 3.0

* use new datasource object in typeorm 3

* fix tests

* fix tests

* migrate before creating connection

* fail the test if migration failed
2022-04-06 10:32:41 +08:00
Jackson Harper
ccedec7703 Make sure we refresh the elastic index when running tests 2022-04-04 21:21:57 -07:00
dependabot[bot]
8df6e750dc
Bump googleapis from 59.0.0 to 100.0.0
Bumps [googleapis](https://github.com/googleapis/google-api-nodejs-client) from 59.0.0 to 100.0.0.
- [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases)
- [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/v59.0.0...googleapis-v100.0.0)

---
updated-dependencies:
- dependency-name: googleapis
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 22:36:25 +00:00
Jackson Harper
62c3bcd968
Merge pull request #338 from omnivore-app/dependabot/npm_and_yarn/opentelemetry/semantic-conventions-1.0.1
Bump @opentelemetry/semantic-conventions from 0.24.0 to 1.0.1
2022-04-04 15:35:51 -07:00
dependabot[bot]
3b4254a711
Bump luxon from 1.28.0 to 2.3.1
Bumps [luxon](https://github.com/moment/luxon) from 1.28.0 to 2.3.1.
- [Release notes](https://github.com/moment/luxon/releases)
- [Changelog](https://github.com/moment/luxon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moment/luxon/compare/1.28.0...2.3.1)

---
updated-dependencies:
- dependency-name: luxon
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 17:55:59 +00:00
Jackson Harper
46c5b8c82a Another attempt at slimming docker file 2022-04-04 10:42:04 -07:00
Jackson Harper
946734d76c Revert docker changes
These were creating fatter images than we want because of the
lerna dependencies.
2022-04-04 09:59:18 -07:00
Jackson Harper
bd6bed746e Remove clean command 2022-04-04 09:19:25 -07:00
Jackson Harper
b15a7b0bd5 Only install dev deps on the prod image 2022-04-04 09:15:56 -07:00
Jackson Harper
9845a49040 Remove semicolon 2022-04-04 08:17:46 -07:00
Jackson Harper
b8b471d369 Move @types into dev 2022-04-04 08:17:00 -07:00
Jackson Harper
c8ec7d636e Use require to import address parser function 2022-04-04 08:11:26 -07:00
Jackson Harper
87077be85e First stage of build is development 2022-04-04 08:11:06 -07:00
Jackson Harper
b668114c33 Fix multistage docker build 2022-04-04 07:50:16 -07:00
Jackson Harper
92925b6808 Prettier fixes 2022-04-03 10:21:16 -07:00
Jackson Harper
fc17daa546 Remove unneeded mocha params 2022-04-02 17:02:11 -07:00
Jackson Harper
f6cfa2f9d2 Revert test files that dont need to be changed 2022-04-02 17:00:45 -07:00
Jackson Harper
da28998130 Pull ul list out of newsletter blurb
next/react doesnt want child elements of the paragraphs

Improve formatting

Improve wording

Use buttons in the subscribe directly blocks

Simplify docs on setting up forwarding rules

Add extra padding on bottom of help docs

Remove unused style

Add emails help page

Improve formatting

Prefetch page content on iOS

Reduce the reader overly length now that items are precached

Add invalidation when highlights are added to items

fix missing index_settings.json file in api dockerfile for creating elastic index (#363)

Handle full email address objects in the to param from sendgrid

These come in a format like:

"jacksonh-dfdf@inbox.omnivore.app" <jacksonh-dfdf@inbox-demo.omnivore.app>

New IDs for short highlights because they dont cascade delete now

Testing CI issues

Simplify test

CI test

Use promises for async tests

Temporarily remove test to debug CI

Re-enable

re-enable test, return error

Specify a userId when looking up saved email pages

create a unique url for newsletters without a URL

Use 500ms on page test timeouts

Increase timeout

Dont use deep equal to match newsletter label

Run just the labels API

Run against just the newsletter emails

Run without the page tests

Fix

Set the allow uncaught flag

Remove highlight tests

Remove newsletters tests

more resolver tests

Remove newsetter tests

Comment out resolver tests

Use nock for external requests in tests

Specify puppeteer url for tests

Comment out more tests

uncomment tests

re-enable

re-enable email test

Re-disable

Re-enable one pdf attachment test

Re-disable pdf attachment test

Use promises on setTimeout tests

rm label tests

mv label tests into a context

Comment out pdf tests

Comment out pdf tests

Async test

Async wrappers

Delay when creating test pages

More debugging

Unique short ids

Remove potentially problematic test

Fetch page before returning for test

handler in before block

more debugging

More debugging

Move errors checks into contexts

Use a context when saving newsletters to force index refresh

Prettier fix

Fix newsletter label check, remove setTimeout

Re-enable test

timeout on pdf router handler

Fix method call

comment out PDF test

Unique fake username

Comment out PDF test

Debugging signed urls

Re-enable

New email

pdf test

PDF tests

Comment out pdf test

Add nock stubs for email URLs

Use full address for PDF test

Remove debug

Use full email addresses
2022-04-02 16:56:24 -07:00
Hongbo Wu
250118de45
fix missing index_settings.json file in api dockerfile for creating elastic index (#363) 2022-04-01 13:07:44 +08:00
gitstart-omnivore
1978a92a1b Effected review corrections 2022-03-31 13:03:50 +00:00
Jackson Harper
a8faaf835c Remove debug sort on labels 2022-03-30 14:13:26 -07:00
Jackson Harper
2c15516d96 Order labels by createdAt so they maintain a consistent order 2022-03-30 13:28:37 -07:00
gitstart-omnivore
11db7be473 [Omn-190] - [Settings View] - Labels 2022-03-30 12:24:29 +00:00
Hongbo Wu
6d405432af
add site_name and site_icon to page model and return in resolver (#341)
* add site_name and site_icon to page model and return in resolver

* fix tests
2022-03-30 10:43:10 +08:00
dependabot[bot]
d0af8b2186
Bump @opentelemetry/semantic-conventions from 0.24.0 to 1.0.1
Bumps [@opentelemetry/semantic-conventions](https://github.com/open-telemetry/opentelemetry-js) from 0.24.0 to 1.0.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-js/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-js/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-js/compare/v0.24.0...stable/v1.0.1)

---
updated-dependencies:
- dependency-name: "@opentelemetry/semantic-conventions"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-28 21:28:57 +00:00
Jackson Harper
2bada0b9df
Merge pull request #293 from omnivore-app/feature/priority-by-rate-limit
Use lower priority queue for large imports
2022-03-28 13:19:35 -07:00
Jackson Harper
d9af397b9c
Merge pull request #331 from omnivore-app/fix/update-page-after-deletion
fix document_missing_exception being thrown to sentry when updating page in elastic
2022-03-28 10:30:31 -07:00
Hongbo Wu
fd18affaec fix document_missing_exception being thrown to sentry when updating page in elastic 2022-03-28 21:16:33 +08:00
Hongbo Wu
b6c04f3508 fix saving report item by linking to elastic page 2022-03-28 20:38:54 +08:00
Jackson Harper
1cdbfaca26
Merge pull request #294 from omnivore-app/feature/add-created-or-updated_at-to-newsletter_email
add created_at and updated_at to newsletter emails and sort by create…
2022-03-25 09:10:54 -07:00
Jackson Harper
5036924b21
Merge pull request #280 from omnivore-app/dependabot/npm_and_yarn/jsdom-19.0.0
Bump jsdom from 16.7.0 to 19.0.0
2022-03-25 09:08:55 -07:00
Hongbo Wu
27735f7310
add page id in updated page json file in gcs (#319) 2022-03-25 13:50:43 +08:00
Hongbo Wu
d595d4a8c4
add success and failure count in assertions (#318) 2022-03-25 12:16:43 +08:00
Hongbo Wu
e7203bebb5
add a function_resolver to return originalArticleUrl from article.url (#317)
* add a function_resolver to return originalArticleUrl from article.url

* add a test
2022-03-25 11:25:30 +08:00
Jackson Harper
0264bc6733
Merge pull request #283 from omnivore-app/dependabot/npm_and_yarn/sentry/integrations-6.19.1
Bump @sentry/integrations from 5.30.0 to 6.19.1
2022-03-23 20:05:09 -07:00
dependabot[bot]
3ec6f22199
Bump jsdom from 16.7.0 to 19.0.0
Bumps [jsdom](https://github.com/jsdom/jsdom) from 16.7.0 to 19.0.0.
- [Release notes](https://github.com/jsdom/jsdom/releases)
- [Changelog](https://github.com/jsdom/jsdom/blob/master/Changelog.md)
- [Commits](https://github.com/jsdom/jsdom/compare/16.7.0...19.0.0)

---
updated-dependencies:
- dependency-name: jsdom
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-23 18:51:08 +00:00
Hongbo Wu
79a7eb11a3 fix data loss by selecting data from links instead of pages 2022-03-23 17:27:55 +08:00
Hongbo Wu
8a485af20d validate publishedAt before inserting to elastic 2022-03-23 14:30:33 +08:00
Hongbo Wu
e1752bb176 uncomment testing code 2022-03-23 12:37:33 +08:00
Hongbo Wu
1b0399f286 add assertion of migrated data in python script 2022-03-23 12:09:25 +08:00
Hongbo Wu
6597cc37b6 add created_at and updated_at to newsletter emails and sort by created_at desc 2022-03-22 18:43:47 +08:00
Hongbo Wu
acec3b1acb Use lower priority queue for large imports
* add a count query in elastic
  * if priority is not set, check the rate limit of user's libary
    - if 5 articles added in the last minute: use low queue
    - default: use normal queue
2022-03-22 18:08:08 +08:00
Hongbo Wu
7d19c933ac add elastic in README 2022-03-22 15:33:51 +08:00
Hongbo Wu
1893e36375
Fix uploading endpoint returns 504 (#289)
* add timeout = 60s for uploading to private bucket

* add debug logs

* send response to client to close connection

* add tests for upload

* add PUBSUB_VERIFICATION_TOKEN in .env.test
2022-03-22 14:20:40 +08:00
Hongbo Wu
3e9063c145
return empty content instead of null in search result (#291) 2022-03-22 13:34:44 +08:00
Hongbo Wu
bee3b3c6fa
fix article_id type mismatch (uuid => varchar) when saving highlights in postgres by setting article_id to be undefined (#285) 2022-03-22 11:48:01 +08:00
Hongbo Wu
4ca7c89622
format date string as yyyy-mm-dd (#288) 2022-03-22 11:46:39 +08:00
Hongbo Wu
c15efe6aad
Fix sentry log size error (#287)
* reduce sentry log size error by partially logging page created in elastic

* remove some debugging logs

* remove more debugging logs
2022-03-22 11:45:58 +08:00
dependabot[bot]
783118a2e4
Bump @sentry/integrations from 5.30.0 to 6.19.1
Bumps [@sentry/integrations](https://github.com/getsentry/sentry-javascript) from 5.30.0 to 6.19.1.
- [Release notes](https://github.com/getsentry/sentry-javascript/releases)
- [Changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-javascript/compare/5.30.0...6.19.1)

---
updated-dependencies:
- dependency-name: "@sentry/integrations"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-21 21:19:05 +00:00
Jackson Harper
f9bce1932c Print the logging level on startup 2022-03-21 09:31:05 -07:00
Hongbo Wu
77050905a5 retry max three times if update labels is conflicted 2022-03-18 10:39:11 +08:00
Hongbo Wu
9d8d2e40d7 reduce time to save reading progress in elastic update 2022-03-18 10:29:01 +08:00
Hongbo Wu
ac567f7e71 retry max three times if update is conflicted 2022-03-18 10:17:20 +08:00
Jackson Harper
7910565dbf
Merge pull request #251 from omnivore-app/fix/jsonld-encoding
Use html decoding when getting values from fetched oembed
2022-03-17 16:53:21 -07:00
Hongbo Wu
563131ea23
Fix/newsletter label not add (#256)
* default sort by savedAt to avoid recent read page to appear on top of the list

* revert lint on generated code

* fix elastic update script syntax error
2022-03-17 13:22:38 +08:00
Hongbo Wu
a2ce98229e
default sort by savedAt to avoid recent read page to appear on top of… (#254)
* default sort by savedAt to avoid recent read page to appear on top of the list

* revert lint on generated code
2022-03-17 10:54:00 +08:00
Hongbo Wu
af037a2837
make readingProgress required in the elastic page data (#253)
* make readingProgress required in the elastic page data

* delete readingProgress from function_resolvers because we have stored them in elastic
2022-03-17 10:06:21 +08:00
Jackson Harper
ff1200f3a1 Use html decoding when getting values from fetched oembed
If we fetch oembed data from an external source, instead of
handling it in readabilityjs we need to html decode it.
2022-03-16 15:29:42 -07:00
Jackson Harper
89f3719ba3 Fix linting 2022-03-16 14:23:39 -07:00
Jackson Harper
0314d8cf17 Add some extra logging 2022-03-16 13:53:55 -07:00
Jackson Harper
dc27c0c7a4 Return 0 if looking up page reading progress fails 2022-03-16 13:33:36 -07:00
Jackson Harper
27143cbedf Remove function handlers for reading progress
These shouldn't be needed anymore because the values are stored
in elastic.
2022-03-16 13:11:36 -07:00
Jackson Harper
88103cba9f
Merge pull request #162 from omnivore-app/dependabot/npm_and_yarn/apollo-datasource-3.3.1
Bump apollo-datasource from 0.7.3 to 3.3.1
2022-03-16 11:03:26 -07:00
Hongbo Wu
07dcd5da26 add label to page only if not exists 2022-03-16 23:00:37 +08:00
Hongbo Wu
1c4dcd7b00 automatically update updatedAt when page is updated in elastic 2022-03-16 22:28:39 +08:00
Hongbo Wu
f412758040 add Newsletter label to the page created by newsletters email 2022-03-16 18:40:05 +08:00
Hongbo Wu
27157006c1
use private bucket to upload page events (#244)
* use private bucket to upload page events

* fix tests

* add GCS_UPLOAD_PRIVATE_BUCKET in test env

* allow GCS_UPLOAD_PRIVATE_BUCKET to be empty
2022-03-16 14:39:07 +08:00
Jackson Harper
e652a6ea8c
Rebased version of the elastic PR (#225)
* Add elastic to our docker compose

* add AND/OR/NOT search operations

* add elastic and create article in elastic

* change error code when elastic throws error

* add search pages in elastic

* add search by labels

* Add elastic to GitHub Action

* Update elastic version

* Fix port for elastic

* add url in search query

* Set elastic features when running tests

* add debug logs

* Use localhost instead of service hostname

* refresh elastic after create/update

* update search labels query

* add typescript support

* search pages in elastic

* fix search queries

* use elastic for saving page

* fix test failure

* update getArticle api to use elastic

* use generic get page function

* add elastic migration python script

* fix bulk helper param

* save elastic page id in article_saving_request instead of postgres article_id

* fix page archiving and deleting

* add tests for deleteArticle

* remove custom date type in elastic mappings which not exist in older version of elastic

* fix timestamp format issue

* add tests for save reading progress

* add tests for save file

* optimize search results

* add alias to index

* update migration script to receive env var as params

* Add failing test to validate we don't decrease reading progress

This test is failing with Elastic because we aren't fetching
the reading progress from elastic here, and are fetching it
from postgres.

* Rename readingProgress to readingProgressPercent

This is the name stored in elastic, so fixes issues pulling the
value out.

* Linting

* Add failing test for creating highlights w/elastic

This test fails because the highlight can't be looked up. Is there
a different ID we should be passing in to query for highlights,
or do we need to update the query to look for elastic_id?

* add tests code coverage threshold

* update nyc config

* include more files in test coverage

* change alias name

* update updateContent to update pages in elastic

* remove debug log

* fix createhighlight test

* search pages by alias in elastic

* update set labels and delete labels in elastic

* migration script enumeration

* make BULK_SIZE an env var

* fix pdf search indexing

* debug github action exit issue

* call pubsub when create/update/delete page in elastic

* fix json parsing bug and reduce reading data from file

* replace a depreciated pubsub api call

* debug github action exit issue

* debug github action exit issue

* add handler to upload elastic page data to GCS

* fix tests

* Use http_auth instead of basic_auth

* add index creation and existing postgres tables update in migration script

* fix a typo to connect to elastic

* rename readingProgress to readingProgressPercent

* migrate elastic_page_id in highlights and article_saving_request tables

* update migration script to include number of updated rows

* update db migration query

* read index mappings from file

* fix upload pages to gcs

* fix tests failure due to pageContext

* fix upload file id not exist error

* Handle savedAt & isArchived attributes w/out quering elastic

* Fix prettier issues

* fix content-type mismatching

* revert pageId to linkId because frontend was not deployed yet

* fix newsletters and attachment not saved in elastic

* put linkId in article for setting labels

* exclude orginalHtml in the result of searching to improve performace

* exclude content in the result of searching to improve performace

* remove score sorting

* do not refresh immediately to reduce searching and indexing time

* do not replace the backup data in gcs

* fix no article id defined in articleSavingRequest

* add logging of elastic api running time

* reduce home feed pagination size to 15

* reduce home feed pagination size to 10

* stop revalidating first page

* do not use a separate api to fetch reading progress

* Remove unused comment

* get reading progress if not exists

* replace ngram tokenizer with standard tokenizer

* fix tests

* remove .env.local

* add sort keyword in searching to sort by score

Co-authored-by: Hongbo Wu <hongbo@omnivore.app>
2022-03-16 12:08:59 +08:00
Jackson Harper
a4533dc016
Merge pull request #201 from omnivore-app/feature/beehiiv-newsletter-support
Support newsletters hosted on beehiiv
2022-03-15 14:03:55 -07:00
Jackson Harper
8e1b4fb1a4 Formatting 2022-03-14 15:36:17 -07:00
Jackson Harper
a81181ee60 Dont make queries for readingProgressPercent unless we have to 2022-03-14 15:22:53 -07:00
Jackson Harper
fc7d972855 Fix typo in readability date handling causing this parse issue
Can remove our special handler for the published date now that we
are pulling it out correctly.
2022-03-14 10:20:19 -07:00
Jackson Harper
5983cfe2a6 Attempt to set publishedDate if readability fails to parse it
This can happen if JSONLD fails to load. The test page here has
an encoding issue that causes the oembed jsonld to fail to load
and then readability fails to parse the date.
2022-03-13 21:23:51 -07:00
Jackson Harper
78660c886d rm debug 2022-03-13 09:06:15 -07:00
Jackson Harper
a874482d11 Dont perform an extra query for isArchived 2022-03-13 09:00:25 -07:00
Jackson Harper
bea7d084c4 SetClaims when creating an email article 2022-03-09 19:45:52 -08:00
Jackson Harper
f7814a0c4a Remove unused function 2022-03-09 19:45:31 -08:00