Commit graph

72 commits

Author SHA1 Message Date
Hongbo Wu
74054cbdbd
Merge pull request #716 from omnivore-app/api-token
Api tokens
2022-05-31 14:22:23 +08:00
Hongbo Wu
c0bb67a6b5 Verify api key for routers too 2022-05-28 22:00:01 +08:00
Hongbo Wu
333b0259ba Fix tests 2022-05-27 18:33:49 +08:00
Hongbo Wu
9051a3f43a Update api key validation 2022-05-27 18:33:49 +08:00
Hongbo Wu
a09588d3a7 Update generateApiKey resolver 2022-05-27 18:33:49 +08:00
Jackson Harper
93b095818d Linting fixes 2022-05-26 21:40:40 -07:00
Jackson Harper
cb98a9cf86 Make clients opt into creating a page when uploading a file 2022-05-26 21:40:40 -07:00
Hongbo Wu
7d4d1d7b67 Parse language in readability 2022-05-26 10:55:21 +08:00
Hongbo Wu
6e06429636 Add language keyword in search query 2022-05-26 10:55:02 +08:00
Hongbo Wu
a35b096d73 Support sort and filter by published in resolver 2022-05-24 18:25:32 +08:00
Hongbo Wu
2ee95a1c14 Fix cannot convert null to object error message 2022-05-20 20:38:30 +08:00
Jackson Harper
eadeccce81 Linting fixes 2022-05-18 11:31:42 -07:00
Jackson Harper
004c766588 If parsing fails, attempt adding <html> wrappers to a document
LinkedDom seems less forgiving and expects the outerHTML of a
document, however older extension versions still send innerHTML.
2022-05-18 10:55:31 -07:00
Hongbo Wu
d68549bcb7 Remove unused code 2022-05-18 15:52:31 +08:00
Hongbo Wu
e76fb02f43 Fix window is not defined for parsing code blocks 2022-05-17 11:01:55 +08:00
Hongbo Wu
1b8850ed33 Fix tests 2022-05-12 17:41:11 +08:00
Hongbo Wu
602d141dec Rename doc to dom 2022-05-12 11:00:32 +08:00
Hongbo Wu
a78a6c6ba4 Replace DomWindow with Document in handlers 2022-05-10 17:01:23 +08:00
Hongbo Wu
6a57281e74 Remove DomWindow usage 2022-05-10 17:00:56 +08:00
Hongbo Wu
acc7654a2f Replace jsdom with linkedom 2022-05-10 16:59:09 +08:00
Hongbo Wu
5698790288 Pass url to readability 2022-05-10 16:53:45 +08:00
Hongbo Wu
59a2639b7d Reduce http call to get jsonld data if title or content or sitename or byline exists 2022-05-09 13:45:45 +08:00
Hongbo Wu
a457c9d128 Update article content only when code blocks exist 2022-05-09 13:45:45 +08:00
Hongbo Wu
eaad96acdd Return parsed dom back to backend 2022-05-06 12:29:08 +08:00
Hongbo Wu
5f5076e864 Highlight code element without reinitialize jsdom 2022-05-06 12:20:54 +08:00
Hongbo Wu
7c6b810522 Remove redundant JSDOM 2022-05-06 10:53:36 +08:00
Hongbo Wu
bc1ed3f054 Check state in articleSavingRequest 2022-05-04 19:33:13 +08:00
Hongbo Wu
2b70d480d2
Remove article saving request (#493)
* Add state and taskName in elastic page mappings

* Add state and taskName in elastic page interface

* Create page with PROCESSING state before scrapping

* Update createArticleRequest API

* Fix tests

* Add default state for pages

* Update createArticle API

* Update save page

* Update save file

* Update saving item description

* Show unable to parse content for failed page

* Fix date parsing

* Search for not failed pages

* Fix tests

* Add test for saveUrl

* Update get article saving request api

* Update get article test

* Add test for articleSavingRequest API

* Add test for failure

* Return new page id if clientRequestId empty

* Update clientRequestId in savePage

* Update clientRequestId in saveFile

* Replace article with slug in articleSavingRequest

* Add slug in articleSavingRequest response

* Depreciate article

* Use slug in web

* Remove article and highlight fragments

* Query article.slug on Prod

* Show unable to parse description for failed page

* Fix a bug having duplicate pages when saving the same url multiple times

* Add state in response

* Rename variables in removeArticle API

* Rename state

* Add state in response in web

* Make state an enum

* Open temporary page by link id

* Use an empty reader view as the background for loading pages

* Progressively load the article page as content is loaded

* Add includePending flag in getArticles API

* Set includePending = true in web

* Add elastic update mappings in migration script

* Add elastic mappings in docker image

* Move index_settings.json to migrate package

* Remove elastic index creation in api

* Move elastic migrations to a separate directory

* Remove index_settings from api docker image

Co-authored-by: Jackson Harper <jacksonh@gmail.com>
2022-04-29 13:41:06 +08:00
Hongbo Wu
71aa66ea9c
Allow search for subscription:name (#461) 2022-04-22 08:47:41 +08:00
Jackson Harper
c2fd58a809 Make landing a restricted username page 2022-04-18 15:22:59 -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
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
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
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
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
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
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
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
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
2184c2a8d3 Parse online URLs for beehiiv newsletters 2022-03-07 15:49:44 -08:00
Jackson Harper
2cb5cc065a Add support for identifying newsletters hosted on beehiiv.com 2022-03-07 15:23:56 -08:00
Jackson Harper
b6fd3e786e Fix parsing authors from page metadata 2022-03-03 19:40:02 -08:00
Jackson Harper
49092b707d Remove async 2022-03-03 19:31:51 -08:00
Jackson Harper
05373ba3c7 add methid to parse content metadata 2022-03-03 17:10:06 -08:00
Jackson Harper
c2e08d0e8f Fetch title and author from page metadate if possible 2022-03-03 15:20:58 -08:00
Jackson Harper
b326a5f8e7 Add more matches on substack icons 2022-03-03 13:42:30 -08:00
Jackson Harper
484cd78ac5 prettier 2022-03-02 23:14:10 -08:00
Jackson Harper
65ce8353dc Attempt to pull URLs for probable newsletter emails out of content 2022-03-02 23:09:10 -08:00