rename variables

This commit is contained in:
Hongbo Wu 2023-11-09 19:00:57 +08:00
parent ffac5c195d
commit 9dfc5f856d
17 changed files with 151 additions and 143 deletions

View file

@ -201,10 +201,10 @@ export class LibraryItem {
hiddenAt?: Date | null
@Column('timestamptz')
sharedAt?: Date | null
addedToFollowingAt?: Date | null
@Column('text')
sharedBy?: string | null
addedToFollowingBy?: string | null
@Column('jsonb')
links?: any | null
@ -212,12 +212,12 @@ export class LibraryItem {
@Column('text')
previewContent?: string | null
@Column('timestamptz')
seenAt?: Date | null
@Column('boolean')
isInLibrary!: boolean
@Column('text')
previewContentType?: string | null
@Column('text')
sharedSource?: string | null
addedToFollowingFrom?: string | null
@Column('timestamptz')
addedToLibraryAt?: Date | null
}

View file

@ -75,5 +75,5 @@ export class Subscription {
isPublic?: boolean | null
@Column('boolean')
isFetchingContent?: boolean | null
autoAddToLibrary?: boolean | null
}

View file

@ -17,24 +17,6 @@ export type Scalars = {
JSON: any;
};
export type AddFollowingToLibraryError = {
__typename?: 'AddFollowingToLibraryError';
errorCodes: Array<AddFollowingToLibraryErrorCode>;
};
export enum AddFollowingToLibraryErrorCode {
AlreadyExists = 'ALREADY_EXISTS',
BadRequest = 'BAD_REQUEST',
Unauthorized = 'UNAUTHORIZED'
}
export type AddFollowingToLibraryResult = AddFollowingToLibraryError | AddFollowingToLibrarySuccess;
export type AddFollowingToLibrarySuccess = {
__typename?: 'AddFollowingToLibrarySuccess';
articleSavingRequest: ArticleSavingRequest;
};
export type AddPopularReadError = {
__typename?: 'AddPopularReadError';
errorCodes: Array<AddPopularReadErrorCode>;
@ -271,6 +253,24 @@ export enum ContentReader {
Web = 'WEB'
}
export type CopyFromFollowingToLibraryError = {
__typename?: 'CopyFromFollowingToLibraryError';
errorCodes: Array<CopyFromFollowingToLibraryErrorCode>;
};
export enum CopyFromFollowingToLibraryErrorCode {
AlreadyExists = 'ALREADY_EXISTS',
BadRequest = 'BAD_REQUEST',
Unauthorized = 'UNAUTHORIZED'
}
export type CopyFromFollowingToLibraryResult = CopyFromFollowingToLibraryError | CopyFromFollowingToLibrarySuccess;
export type CopyFromFollowingToLibrarySuccess = {
__typename?: 'CopyFromFollowingToLibrarySuccess';
articleSavingRequest: ArticleSavingRequest;
};
export type CreateArticleError = {
__typename?: 'CreateArticleError';
errorCodes: Array<CreateArticleErrorCode>;
@ -1303,9 +1303,9 @@ export type MoveLabelSuccess = {
export type Mutation = {
__typename?: 'Mutation';
addFollowingToLibrary: AddFollowingToLibraryResult;
addPopularRead: AddPopularReadResult;
bulkAction: BulkActionResult;
copyFromFollowingToLibrary: CopyFromFollowingToLibraryResult;
createArticle: CreateArticleResult;
createArticleSavingRequest: CreateArticleSavingRequestResult;
createGroup: CreateGroupResult;
@ -1366,11 +1366,6 @@ export type Mutation = {
};
export type MutationAddFollowingToLibraryArgs = {
id: Scalars['ID'];
};
export type MutationAddPopularReadArgs = {
name: Scalars['String'];
};
@ -1385,6 +1380,11 @@ export type MutationBulkActionArgs = {
};
export type MutationCopyFromFollowingToLibraryArgs = {
id: Scalars['ID'];
};
export type MutationCreateArticleArgs = {
input: CreateArticleInput;
};
@ -3404,10 +3404,6 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs
/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
AddFollowingToLibraryError: ResolverTypeWrapper<AddFollowingToLibraryError>;
AddFollowingToLibraryErrorCode: AddFollowingToLibraryErrorCode;
AddFollowingToLibraryResult: ResolversTypes['AddFollowingToLibraryError'] | ResolversTypes['AddFollowingToLibrarySuccess'];
AddFollowingToLibrarySuccess: ResolverTypeWrapper<AddFollowingToLibrarySuccess>;
AddPopularReadError: ResolverTypeWrapper<AddPopularReadError>;
AddPopularReadErrorCode: AddPopularReadErrorCode;
AddPopularReadResult: ResolversTypes['AddPopularReadError'] | ResolversTypes['AddPopularReadSuccess'];
@ -3446,6 +3442,10 @@ export type ResolversTypes = {
BulkActionSuccess: ResolverTypeWrapper<BulkActionSuccess>;
BulkActionType: BulkActionType;
ContentReader: ContentReader;
CopyFromFollowingToLibraryError: ResolverTypeWrapper<CopyFromFollowingToLibraryError>;
CopyFromFollowingToLibraryErrorCode: CopyFromFollowingToLibraryErrorCode;
CopyFromFollowingToLibraryResult: ResolversTypes['CopyFromFollowingToLibraryError'] | ResolversTypes['CopyFromFollowingToLibrarySuccess'];
CopyFromFollowingToLibrarySuccess: ResolverTypeWrapper<CopyFromFollowingToLibrarySuccess>;
CreateArticleError: ResolverTypeWrapper<CreateArticleError>;
CreateArticleErrorCode: CreateArticleErrorCode;
CreateArticleInput: CreateArticleInput;
@ -3926,9 +3926,6 @@ export type ResolversTypes = {
/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
AddFollowingToLibraryError: AddFollowingToLibraryError;
AddFollowingToLibraryResult: ResolversParentTypes['AddFollowingToLibraryError'] | ResolversParentTypes['AddFollowingToLibrarySuccess'];
AddFollowingToLibrarySuccess: AddFollowingToLibrarySuccess;
AddPopularReadError: AddPopularReadError;
AddPopularReadResult: ResolversParentTypes['AddPopularReadError'] | ResolversParentTypes['AddPopularReadSuccess'];
AddPopularReadSuccess: AddPopularReadSuccess;
@ -3957,6 +3954,9 @@ export type ResolversParentTypes = {
BulkActionError: BulkActionError;
BulkActionResult: ResolversParentTypes['BulkActionError'] | ResolversParentTypes['BulkActionSuccess'];
BulkActionSuccess: BulkActionSuccess;
CopyFromFollowingToLibraryError: CopyFromFollowingToLibraryError;
CopyFromFollowingToLibraryResult: ResolversParentTypes['CopyFromFollowingToLibraryError'] | ResolversParentTypes['CopyFromFollowingToLibrarySuccess'];
CopyFromFollowingToLibrarySuccess: CopyFromFollowingToLibrarySuccess;
CreateArticleError: CreateArticleError;
CreateArticleInput: CreateArticleInput;
CreateArticleResult: ResolversParentTypes['CreateArticleError'] | ResolversParentTypes['CreateArticleSuccess'];
@ -4338,20 +4338,6 @@ export type SanitizeDirectiveArgs = {
export type SanitizeDirectiveResolver<Result, Parent, ContextType = ResolverContext, Args = SanitizeDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;
export type AddFollowingToLibraryErrorResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['AddFollowingToLibraryError'] = ResolversParentTypes['AddFollowingToLibraryError']> = {
errorCodes?: Resolver<Array<ResolversTypes['AddFollowingToLibraryErrorCode']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AddFollowingToLibraryResultResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['AddFollowingToLibraryResult'] = ResolversParentTypes['AddFollowingToLibraryResult']> = {
__resolveType: TypeResolveFn<'AddFollowingToLibraryError' | 'AddFollowingToLibrarySuccess', ParentType, ContextType>;
};
export type AddFollowingToLibrarySuccessResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['AddFollowingToLibrarySuccess'] = ResolversParentTypes['AddFollowingToLibrarySuccess']> = {
articleSavingRequest?: Resolver<ResolversTypes['ArticleSavingRequest'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AddPopularReadErrorResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['AddPopularReadError'] = ResolversParentTypes['AddPopularReadError']> = {
errorCodes?: Resolver<Array<ResolversTypes['AddPopularReadErrorCode']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
@ -4528,6 +4514,20 @@ export type BulkActionSuccessResolvers<ContextType = ResolverContext, ParentType
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type CopyFromFollowingToLibraryErrorResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['CopyFromFollowingToLibraryError'] = ResolversParentTypes['CopyFromFollowingToLibraryError']> = {
errorCodes?: Resolver<Array<ResolversTypes['CopyFromFollowingToLibraryErrorCode']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type CopyFromFollowingToLibraryResultResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['CopyFromFollowingToLibraryResult'] = ResolversParentTypes['CopyFromFollowingToLibraryResult']> = {
__resolveType: TypeResolveFn<'CopyFromFollowingToLibraryError' | 'CopyFromFollowingToLibrarySuccess', ParentType, ContextType>;
};
export type CopyFromFollowingToLibrarySuccessResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['CopyFromFollowingToLibrarySuccess'] = ResolversParentTypes['CopyFromFollowingToLibrarySuccess']> = {
articleSavingRequest?: Resolver<ResolversTypes['ArticleSavingRequest'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type CreateArticleErrorResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['CreateArticleError'] = ResolversParentTypes['CreateArticleError']> = {
errorCodes?: Resolver<Array<ResolversTypes['CreateArticleErrorCode']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
@ -5273,9 +5273,9 @@ export type MoveLabelSuccessResolvers<ContextType = ResolverContext, ParentType
};
export type MutationResolvers<ContextType = ResolverContext, ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation']> = {
addFollowingToLibrary?: Resolver<ResolversTypes['AddFollowingToLibraryResult'], ParentType, ContextType, RequireFields<MutationAddFollowingToLibraryArgs, 'id'>>;
addPopularRead?: Resolver<ResolversTypes['AddPopularReadResult'], ParentType, ContextType, RequireFields<MutationAddPopularReadArgs, 'name'>>;
bulkAction?: Resolver<ResolversTypes['BulkActionResult'], ParentType, ContextType, RequireFields<MutationBulkActionArgs, 'action' | 'query'>>;
copyFromFollowingToLibrary?: Resolver<ResolversTypes['CopyFromFollowingToLibraryResult'], ParentType, ContextType, RequireFields<MutationCopyFromFollowingToLibraryArgs, 'id'>>;
createArticle?: Resolver<ResolversTypes['CreateArticleResult'], ParentType, ContextType, RequireFields<MutationCreateArticleArgs, 'input'>>;
createArticleSavingRequest?: Resolver<ResolversTypes['CreateArticleSavingRequestResult'], ParentType, ContextType, RequireFields<MutationCreateArticleSavingRequestArgs, 'input'>>;
createGroup?: Resolver<ResolversTypes['CreateGroupResult'], ParentType, ContextType, RequireFields<MutationCreateGroupArgs, 'input'>>;
@ -6344,9 +6344,6 @@ export type WebhooksSuccessResolvers<ContextType = ResolverContext, ParentType e
};
export type Resolvers<ContextType = ResolverContext> = {
AddFollowingToLibraryError?: AddFollowingToLibraryErrorResolvers<ContextType>;
AddFollowingToLibraryResult?: AddFollowingToLibraryResultResolvers<ContextType>;
AddFollowingToLibrarySuccess?: AddFollowingToLibrarySuccessResolvers<ContextType>;
AddPopularReadError?: AddPopularReadErrorResolvers<ContextType>;
AddPopularReadResult?: AddPopularReadResultResolvers<ContextType>;
AddPopularReadSuccess?: AddPopularReadSuccessResolvers<ContextType>;
@ -6372,6 +6369,9 @@ export type Resolvers<ContextType = ResolverContext> = {
BulkActionError?: BulkActionErrorResolvers<ContextType>;
BulkActionResult?: BulkActionResultResolvers<ContextType>;
BulkActionSuccess?: BulkActionSuccessResolvers<ContextType>;
CopyFromFollowingToLibraryError?: CopyFromFollowingToLibraryErrorResolvers<ContextType>;
CopyFromFollowingToLibraryResult?: CopyFromFollowingToLibraryResultResolvers<ContextType>;
CopyFromFollowingToLibrarySuccess?: CopyFromFollowingToLibrarySuccessResolvers<ContextType>;
CreateArticleError?: CreateArticleErrorResolvers<ContextType>;
CreateArticleResult?: CreateArticleResultResolvers<ContextType>;
CreateArticleSavingRequestError?: CreateArticleSavingRequestErrorResolvers<ContextType>;

View file

@ -1,21 +1,5 @@
directive @sanitize(allowedTags: [String], maxLength: Int, minLength: Int, pattern: String) on INPUT_FIELD_DEFINITION
type AddFollowingToLibraryError {
errorCodes: [AddFollowingToLibraryErrorCode!]!
}
enum AddFollowingToLibraryErrorCode {
ALREADY_EXISTS
BAD_REQUEST
UNAUTHORIZED
}
union AddFollowingToLibraryResult = AddFollowingToLibraryError | AddFollowingToLibrarySuccess
type AddFollowingToLibrarySuccess {
articleSavingRequest: ArticleSavingRequest!
}
type AddPopularReadError {
errorCodes: [AddPopularReadErrorCode!]!
}
@ -227,6 +211,22 @@ enum ContentReader {
WEB
}
type CopyFromFollowingToLibraryError {
errorCodes: [CopyFromFollowingToLibraryErrorCode!]!
}
enum CopyFromFollowingToLibraryErrorCode {
ALREADY_EXISTS
BAD_REQUEST
UNAUTHORIZED
}
union CopyFromFollowingToLibraryResult = CopyFromFollowingToLibraryError | CopyFromFollowingToLibrarySuccess
type CopyFromFollowingToLibrarySuccess {
articleSavingRequest: ArticleSavingRequest!
}
type CreateArticleError {
errorCodes: [CreateArticleErrorCode!]!
}
@ -1166,9 +1166,9 @@ type MoveLabelSuccess {
}
type Mutation {
addFollowingToLibrary(id: ID!): AddFollowingToLibraryResult!
addPopularRead(name: String!): AddPopularReadResult!
bulkAction(action: BulkActionType!, async: Boolean, expectedCount: Int, labelIds: [ID!], query: String!): BulkActionResult!
copyFromFollowingToLibrary(id: ID!): CopyFromFollowingToLibraryResult!
createArticle(input: CreateArticleInput!): CreateArticleResult!
createArticleSavingRequest(input: CreateArticleSavingRequestInput!): CreateArticleSavingRequestResult!
createGroup(input: CreateGroupInput!): CreateGroupResult!

View file

@ -1,14 +1,14 @@
import { IsNull, Not } from 'typeorm'
import { LibraryItem } from '../../entity/library_item'
import {
AddFollowingToLibraryError,
AddFollowingToLibraryErrorCode,
AddFollowingToLibrarySuccess,
CopyFromFollowingToLibraryError,
CopyFromFollowingToLibraryErrorCode,
CopyFromFollowingToLibrarySuccess,
FeedEdge,
FeedsError,
FeedsErrorCode,
FeedsSuccess,
MutationAddFollowingToLibraryArgs,
MutationCopyFromFollowingToLibraryArgs,
QueryFeedsArgs,
} from '../../generated/graphql'
import { feedRepository } from '../../repository/feed'
@ -20,7 +20,7 @@ import {
libraryItemToArticleSavingRequest,
} from '../../utils/helpers'
export const feedsResolve = authorized<
export const feedsResolver = authorized<
FeedsSuccess,
FeedsError,
QueryFeedsArgs
@ -72,14 +72,14 @@ export const feedsResolve = authorized<
}
})
export const addFollowingToLibraryResolver = authorized<
AddFollowingToLibrarySuccess,
AddFollowingToLibraryError,
MutationAddFollowingToLibraryArgs
export const copyFromFollowingToLibraryResolver = authorized<
CopyFromFollowingToLibrarySuccess,
CopyFromFollowingToLibraryError,
MutationCopyFromFollowingToLibraryArgs
>(async (_, { id }, { authTrx, pubsub, uid }) => {
analytics.track({
userId: uid,
event: 'add_following_to_library',
event: 'copy_from_following_to_library',
properties: {
id,
},
@ -89,7 +89,7 @@ export const addFollowingToLibraryResolver = authorized<
tx.getRepository(LibraryItem).findOne({
where: {
id,
sharedAt: Not(IsNull()),
addedToFollowingAt: Not(IsNull()),
},
relations: ['user'],
})
@ -97,16 +97,18 @@ export const addFollowingToLibraryResolver = authorized<
if (!item) {
return {
errorCodes: [AddFollowingToLibraryErrorCode.Unauthorized],
errorCodes: [CopyFromFollowingToLibraryErrorCode.Unauthorized],
}
}
if (item.isInLibrary) {
if (item.addedToLibraryAt) {
return {
errorCodes: [AddFollowingToLibraryErrorCode.AlreadyExists],
errorCodes: [CopyFromFollowingToLibraryErrorCode.AlreadyExists],
}
}
const addedToLibraryAt = new Date()
// if the content is not fetched yet, create a page save request
if (!item.readableContent) {
const articleSavingRequest = await createPageSaveRequest({
@ -115,11 +117,12 @@ export const addFollowingToLibraryResolver = authorized<
articleSavingRequestId: id,
priority: 'high',
publishedAt: item.publishedAt || undefined,
savedAt: addedToLibraryAt,
pubsub,
})
return {
__typename: 'AddFollowingToLibrarySuccess',
__typename: 'CopyFromFollowingToLibrarySuccess',
articleSavingRequest,
}
}
@ -127,15 +130,15 @@ export const addFollowingToLibraryResolver = authorized<
const updatedItem = await updateLibraryItem(
item.id,
{
isInLibrary: true,
savedAt: new Date(),
savedAt: addedToLibraryAt,
addedToLibraryAt,
},
uid,
pubsub
)
return {
__typename: 'AddFollowingToLibrarySuccess',
__typename: 'CopyFromFollowingToLibrarySuccess',
articleSavingRequest: libraryItemToArticleSavingRequest(
updatedItem.user,
updatedItem

View file

@ -29,6 +29,7 @@ import {
generateUploadFilePathName,
} from '../utils/uploads'
import { optInFeatureResolver } from './features'
import { copyFromFollowingToLibraryResolver, feedsResolver } from './following'
import { uploadImportFileResolver } from './importers/uploadImportFileResolver'
import {
addPopularReadResolver,
@ -215,6 +216,7 @@ export const functionResolvers = {
updateSubscription: updateSubscriptionResolver,
updateFilter: updateFilterResolver,
updateEmail: updateEmailResolver,
copyFromFollowingToLibrary: copyFromFollowingToLibraryResolver,
},
Query: {
me: getMeUserResolver,
@ -246,6 +248,7 @@ export const functionResolvers = {
filters: filtersResolver,
groups: groupsResolver,
recentEmails: recentEmailsResolver,
feeds: feedsResolver,
},
User: {
async intercomHash(

View file

@ -213,7 +213,7 @@ export const subscribeResolver = authorized<
scheduledDates: [new Date()], // fetch immediately
fetchedDates: [updatedSubscription.lastFetchedAt || null],
checksums: [updatedSubscription.lastFetchedChecksum || null],
isFetchingContents: [!!updatedSubscription.isFetchingContent],
addToLibraryFlags: [!!updatedSubscription.autoAddToLibrary],
})
return {
@ -261,7 +261,7 @@ export const subscribeResolver = authorized<
scheduledDates: [new Date()], // fetch immediately
fetchedDates: [null],
checksums: [null],
isFetchingContents: [!!newSubscription.isFetchingContent],
addToLibraryFlags: [!!newSubscription.autoAddToLibrary],
})
return {

View file

@ -3,20 +3,21 @@ import express from 'express'
import { saveFeedItemInFollowing } from '../../services/library_item'
import { logger } from '../../utils/logger'
type SharedSource = 'feed' | 'newsletter' | 'user'
type SourceOfFollowing = 'feed' | 'newsletter' | 'user'
export interface SaveFollowingItemRequest {
userIds: string[]
title: string
url: string
itemId: string
sharedAt: Date
sharedBy: string
sharedSource: SharedSource
addedToFollowingAt: Date
addedToFollowingBy: string
addedToFollowingFrom: SourceOfFollowing
author?: string
description?: string
links?: any
previewContent?: string
previewContentType?: string
publishedAt?: Date
savedAt?: Date
}
@ -26,9 +27,9 @@ function isSaveFollowingItemRequest(
): body is SaveFollowingItemRequest {
return (
'userIds' in body &&
'sharedAt' in body &&
'sharedBy' in body &&
'sharedSource' in body &&
'addedToFollowingAt' in body &&
'addedToFollowingBy' in body &&
'addedToFollowingFrom' in body &&
'url' in body &&
'itemId' in body &&
'title' in body
@ -51,7 +52,7 @@ export function followingServiceRouter() {
return res.status(400).send('INVALID_REQUEST_BODY')
}
if (req.body.sharedSource === 'feed') {
if (req.body.addedToFollowingFrom === 'feed') {
logger.info('saving feed item')
const result = await saveFeedItemInFollowing(req.body)

View file

@ -35,7 +35,7 @@ export function rssFeedRouter() {
ARRAY_AGG(last_fetched_at) AS "fetchedDates",
ARRAY_AGG(coalesce(scheduled_at, NOW())) AS "scheduledDates",
ARRAY_AGG(last_fetched_checksum) AS checksums,
ARRAY_AGG(coalesce(is_fetching_content, false)) AS "isFetchingContents"
ARRAY_AGG(coalesce(auto_add_to_library, false)) AS "addToLibraryFlags"
FROM
omnivore.subscriptions
WHERE

View file

@ -2649,19 +2649,19 @@ const schema = gql`
author: String
}
union AddFollowingToLibraryResult =
AddFollowingToLibrarySuccess
| AddFollowingToLibraryError
union CopyFromFollowingToLibraryResult =
CopyFromFollowingToLibrarySuccess
| CopyFromFollowingToLibraryError
type AddFollowingToLibrarySuccess {
type CopyFromFollowingToLibrarySuccess {
articleSavingRequest: ArticleSavingRequest!
}
type AddFollowingToLibraryError {
errorCodes: [AddFollowingToLibraryErrorCode!]!
type CopyFromFollowingToLibraryError {
errorCodes: [CopyFromFollowingToLibraryErrorCode!]!
}
enum AddFollowingToLibraryErrorCode {
enum CopyFromFollowingToLibraryErrorCode {
UNAUTHORIZED
BAD_REQUEST
ALREADY_EXISTS
@ -2770,7 +2770,7 @@ const schema = gql`
updateSubscription(
input: UpdateSubscriptionInput!
): UpdateSubscriptionResult!
addFollowingToLibrary(id: ID!): AddFollowingToLibraryResult!
copyFromFollowingToLibrary(id: ID!): CopyFromFollowingToLibraryResult!
}
# FIXME: remove sort from feedArticles after all cached tabs are closed

View file

@ -133,7 +133,7 @@ export const createPageSaveRequest = async ({
// reset state to processing if not in following
if (
libraryItem.state !== LibraryItemState.Processing &&
!libraryItem.sharedAt
!libraryItem.addedToFollowingAt
) {
libraryItem = await updateLibraryItem(
libraryItem.id,

View file

@ -576,9 +576,9 @@ export const saveFeedItemInFollowing = (input: SaveFollowingItemRequest) => {
input.userIds.map((userId) => ({
...input,
user: { id: userId },
isInLibrary: false,
originalUrl: input.url,
subscription: input.sharedBy,
subscription: input.addedToFollowingBy,
addedToLibraryAt: null,
}))
return tx

View file

@ -144,7 +144,6 @@ export const savePage = async (
...itemToSave,
id: undefined,
slug: undefined,
isInLibrary: true,
} as QueryDeepPartialEntity<LibraryItem>,
user.id
)
@ -275,5 +274,6 @@ export const parsedContentToLibraryItem = ({
subscription: rssFeedUrl,
archivedAt:
state === ArticleSavingRequestStatus.Archived ? new Date() : undefined,
addedToLibraryAt: validatedDate(saveTime),
}
}

View file

@ -615,7 +615,7 @@ export interface RssSubscriptionGroup {
fetchedDates: (Date | null)[]
scheduledDates: Date[]
checksums: (string | null)[]
isFetchingContents: boolean[]
addToLibraryFlags: boolean[]
}
export const enqueueRssFeedFetch = async (
@ -633,7 +633,7 @@ export const enqueueRssFeedFetch = async (
timestamp.getTime()
), // unix timestamp in milliseconds
userIds: subscriptionGroup.userIds,
isFetchingContents: subscriptionGroup.isFetchingContents,
addToLibraryFlags: subscriptionGroup.addToLibraryFlags,
}
// If there is no Google Cloud Project Id exposed, it means that we are in local environment

View file

@ -6,17 +6,17 @@ BEGIN;
ALTER TABLE omnivore.subscriptions
ADD COLUMN is_public boolean,
ADD COLUMN is_fetching_content boolean;
ADD COLUMN auto_add_to_library boolean;
ALTER TABLE omnivore.library_item
ADD COLUMN hidden_at timestamptz,
ADD COLUMN shared_at timestamptz,
ADD COLUMN shared_by text,
ADD COLUMN added_to_following_at timestamptz,
ADD COLUMN added_to_following_by text,
ADD COLUMN links jsonb,
ADD COLUMN preview_content text,
ADD COLUMN seen_at timestamptz,
ADD COLUMN shared_source text,
ADD COLUMN is_in_library boolean NOT NULL DEFAULT true;
ADD COLUMN preview_content_type text,
ADD COLUMN added_to_following_from text,
ADD COLUMN added_to_library_at timestamptz DEFAULT current_timestamp;
CREATE POLICY library_item_admin_policy on omnivore.library_item
FOR ALL

View file

@ -10,16 +10,16 @@ DROP policy library_item_admin_policy ON omnivore.library_item;
ALTER TABLE omnivore.library_item
DROP COLUMN hidden_at,
DROP COLUMN shared_at,
DROP COLUMN shared_by,
DROP COLUMN added_to_following_at,
DROP COLUMN added_to_following_by,
DROP COLUMN links,
DROP COLUMN preview_content_type,
DROP COLUMN preview_content,
DROP COLUMN seen_at,
DROP COLUMN shared_source,
DROP COLUMN is_in_library;
DROP COLUMN added_to_following_from,
DROP COLUMN added_to_library_at;
ALTER TABLE omnivore.subscriptions
DROP COLUMN is_public,
DROP COLUMN is_fetching_content;
DROP COLUMN auto_add_to_library;
COMMIT;

View file

@ -18,7 +18,7 @@ interface RssFeedRequest {
scheduledTimestamps: number[] // unix timestamp in milliseconds
lastFetchedChecksums: string[]
userIds: string[]
isFetchingContents: boolean[]
addToLibraryFlags: boolean[]
}
// link can be a string or an object
@ -32,7 +32,7 @@ function isRssFeedRequest(body: any): body is RssFeedRequest {
'scheduledTimestamps' in body &&
'userIds' in body &&
'lastFetchedChecksums' in body &&
'isFetchingContents' in body
'addToLibraryFlags' in body
)
}
@ -130,9 +130,9 @@ const createTask = async (
userId: string,
feedUrl: string,
item: Item,
isFetchingContent: boolean
autoAddToLibrary: boolean
) => {
if (isFetchingContent) {
if (autoAddToLibrary) {
return createSavingItemTask(userId, feedUrl, item)
}
@ -179,12 +179,13 @@ const createFollowingTask = async (
title: item.title,
author: item.creator,
description: item.summary,
sharedSource: 'feed',
previewContent: item.content,
sharedBy: feedUrl,
addedToFollowingFrom: 'feed',
previewContent: item.content || item.contentSnippet,
addedToFollowingBy: feedUrl,
savedAt: item.isoDate,
publishedAt: item.isoDate,
sharedAt: item.isoDate,
addedToFollowingAt: item.isoDate,
previewContentType: 'text/html', // TODO: get content type from feed
}
try {
@ -297,7 +298,7 @@ const processSubscription = async (
lastFetchedAt: number,
scheduledAt: number,
lastFetchedChecksum: string,
isFetchingContent: boolean,
autoAddToLibrary: boolean,
feed: {
lastBuildDate: any
'syn:updatePeriod': any
@ -380,7 +381,7 @@ const processSubscription = async (
continue
}
const created = await createTask(userId, feedUrl, item, isFetchingContent)
const created = await createTask(userId, feedUrl, item, autoAddToLibrary)
if (!created) {
console.error('Failed to create task for feed item', item.link)
continue
@ -407,7 +408,7 @@ const processSubscription = async (
userId,
feedUrl,
lastValidItem,
isFetchingContent
autoAddToLibrary
)
if (!created) {
console.error('Failed to create task for feed item', lastValidItem.link)
@ -454,7 +455,7 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
scheduledTimestamps,
userIds,
lastFetchedChecksums,
isFetchingContents,
addToLibraryFlags,
} = req.body
console.log('Processing feed', feedUrl)
@ -472,7 +473,7 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
lastFetchedTimestamps[i],
scheduledTimestamps[i],
lastFetchedChecksums[i],
isFetchingContents[i],
addToLibraryFlags[i],
feed
)
)