mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add public item source
This commit is contained in:
parent
0a8cc13ac5
commit
67dac9ba31
5 changed files with 63 additions and 11 deletions
|
|
@ -2,10 +2,13 @@ import {
|
|||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { PublicItemSource } from './public_item_source'
|
||||
import { PublicItemStats } from './public_item_stats'
|
||||
|
||||
@Entity({ name: 'public_item' })
|
||||
|
|
@ -16,6 +19,10 @@ export class PublicItem {
|
|||
@OneToOne(() => PublicItemStats)
|
||||
stats!: PublicItemStats
|
||||
|
||||
@ManyToOne(() => PublicItemSource)
|
||||
@JoinColumn({ name: 'source_id' })
|
||||
source!: PublicItemSource
|
||||
|
||||
@Column('text')
|
||||
siteIcon?: string
|
||||
|
||||
|
|
|
|||
40
packages/api/src/entity/public_item_source.ts
Normal file
40
packages/api/src/entity/public_item_source.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
|
||||
@Entity({ name: 'public_item_source' })
|
||||
export class PublicItemSource {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string
|
||||
|
||||
@Column('text')
|
||||
type!: string
|
||||
|
||||
@Column('text')
|
||||
name!: string
|
||||
|
||||
@Column('text')
|
||||
url?: string
|
||||
|
||||
@Column('boolean')
|
||||
approved!: boolean
|
||||
|
||||
@Column('text')
|
||||
icon?: string
|
||||
|
||||
@Column('text')
|
||||
topics?: string[]
|
||||
|
||||
@Column('text')
|
||||
languageCodes?: string[]
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt!: Date
|
||||
}
|
||||
|
|
@ -103,12 +103,11 @@ const publicItemToCandidate = (item: PublicItem): FeedItem => ({
|
|||
likeCount: item.stats.likeCount,
|
||||
broadcastCount: item.stats.broadcastCount,
|
||||
siteIcon: item.siteIcon,
|
||||
// TODO
|
||||
subscriptionType: 'public',
|
||||
subscriptionType: item.type,
|
||||
subscription: {
|
||||
id: item.id,
|
||||
name: item.siteName || '',
|
||||
icon: item.siteIcon,
|
||||
id: item.source.id,
|
||||
name: item.source.name,
|
||||
icon: item.source.icon,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ export const findUnseenPublicItems = async (
|
|||
'stats',
|
||||
'stats.public_item_id = public_item.id'
|
||||
)
|
||||
.innerJoin(
|
||||
'public_item_source',
|
||||
'source',
|
||||
'source.id = public_item.source_id'
|
||||
)
|
||||
.where('interaction.user_id = :userId', { userId })
|
||||
.andWhere('interaction.seen_at IS NULL')
|
||||
.orderBy('public_item.createdAt', 'DESC')
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ BEGIN;
|
|||
CREATE TABLE omnivore.public_item_source (
|
||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
|
||||
name TEXT NOT NULL,
|
||||
topics TEXT[] NOT NULL,
|
||||
thumbnail TEXT,
|
||||
url TEXT NOT NULL,
|
||||
language_codes TEXT[] NOT NULL,
|
||||
type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
|
||||
topics TEXT[],
|
||||
icon TEXT,
|
||||
url TEXT,
|
||||
language_codes TEXT[],
|
||||
approved BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
|
|
@ -22,8 +23,8 @@ GRANT SELECT ON omnivore.public_item_source TO omnivore_user;
|
|||
|
||||
CREATE TABLE omnivore.public_item (
|
||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
|
||||
source_name TEXT NOT NULL,
|
||||
source_icon TEXT,
|
||||
source_id uuid NOT NULL REFERENCES omnivore.public_item_source(id) ON DELETE CASCADE,
|
||||
site_icon TEXT,
|
||||
type TEXT NOT NULL, -- public feeds, newsletters, or user recommended
|
||||
title TEXT NOT NULL,
|
||||
url TEXT NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue