Skip to content

Commit

Permalink
Merge pull request #720 from podverse/develop
Browse files Browse the repository at this point in the history
Release v4.15.21
  • Loading branch information
mitchdowney authored Jan 4, 2024
2 parents acb3701 + 10c3c8f commit 78892c9
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ FCM_GOOGLE_API_AUTH_TOKEN=

MAINTENANCE_MODE_ENABLED= # lowercase true to enable
MAINTENANCE_MODE_DOWNTIME_EXPECTED= # in minutes
MAINTENANCE_MODE_SCHEDULED_START_TIME= # datetime
MAINTENANCE_MODE_SCHEDULED_END_TIME= # datetime
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
docker stop podverse_api_prod
docker rm podverse_api_prod
docker image rm podverse/podverse_api:latest
docker compose -f /opt/podverse-ops/docker-compose/prod/srv/docker-compose.yml up -d podverse_api
docker compose -f /opt/podverse-ops/docker-compose/prod/srv/docker-compose.yml up --quiet-pull -d podverse_api
- name: send deploy finished message to Matrix Alerts room
uses: s3krit/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podverse-api",
"version": "4.15.20",
"version": "4.15.21",
"description": "Data API, database migration scripts, and backend services for all Podverse models.",
"contributors": [
"Mitch Downey"
Expand Down Expand Up @@ -200,7 +200,7 @@
"paypal-rest-sdk": "2.0.0-rc.2",
"pg": "8.7.3",
"podcast-partytime": "4.6.2",
"podverse-shared": "^4.14.15",
"podverse-shared": "4.15.2",
"reflect-metadata": "0.1.13",
"request": "^2.88.2",
"request-promise-native": "1.0.8",
Expand Down
14 changes: 13 additions & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export interface Config {
maintenanceMode: {
isEnabled: boolean
downtimeExpected: number
scheduled: {
startTime: Date | null
endTime: Date | null
}
}
}

Expand Down Expand Up @@ -251,7 +255,15 @@ const config: Config = {
isEnabled: process.env.MAINTENANCE_MODE_ENABLED === 'true' || false,
downtimeExpected: process.env.MAINTENANCE_MODE_DOWNTIME_EXPECTED
? parseInt(process.env.MAINTENANCE_MODE_DOWNTIME_EXPECTED)
: 0
: 0,
scheduled: {
startTime: process.env.MAINTENANCE_MODE_SCHEDULED_START_TIME
? new Date(process.env.MAINTENANCE_MODE_SCHEDULED_START_TIME)
: null,
endTime: process.env.MAINTENANCE_MODE_SCHEDULED_END_TIME
? new Date(process.env.MAINTENANCE_MODE_SCHEDULED_END_TIME)
: null
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/entities/episode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Funding,
SocialInteraction,
Transcript,
ValueTag
ValueTagOriginal
} from 'podverse-shared'
import {
Author,
Expand Down Expand Up @@ -198,7 +198,7 @@ export class Episode {
transcript: Transcript[]

@Column('simple-json', { nullable: true })
value: ValueTag[]
value: ValueTagOriginal[]

@ManyToMany((type) => Author)
@JoinTable()
Expand Down
4 changes: 2 additions & 2 deletions src/entities/episodes_most_recent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Funding,
SocialInteraction,
Transcript,
ValueTag
ValueTagOriginal
} from 'podverse-shared'
import { Column, JoinTable, ManyToMany, ManyToOne, ViewColumn, ViewEntity } from 'typeorm'
import { Author, Category, Podcast } from '~/entities'
Expand Down Expand Up @@ -115,7 +115,7 @@ export class EpisodeMostRecent {
transcript: Transcript[]

@Column('simple-json', { nullable: true })
value: ValueTag[]
value: ValueTagOriginal[]

@ManyToMany((type) => Author)
@JoinTable()
Expand Down
25 changes: 2 additions & 23 deletions src/entities/podcast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { IsUrl, IsInt, Min, ValidateIf } from 'class-validator'
import type { LiveItemStatus, PodcastMedium } from 'podverse-shared'
import { podcastItunesTypeDefaultValue, LiveItemStatus, PodcastMedium, ValueTagOriginal } from 'podverse-shared'
import { Author, Category, Episode, FeedUrl, Notification } from '~/entities'
import {
BeforeInsert,
Expand All @@ -18,33 +18,12 @@ import {
UpdateDateColumn
} from 'typeorm'
import { generateShortId } from '~/lib/utility'
import { Phase6ValueTimeSplit } from 'podcast-partytime/dist/parser/phase/phase-6'

type Funding = {
url: string
value?: string
}

export type Value = {
method: string
suggested?: string
type: string
recipients: ValueRecipient[]
valueTimeSplits?: Phase6ValueTimeSplit[]
}

type ValueRecipient = {
address: string
customKey?: string
customValue?: string
fee?: boolean
name?: string
split: string
type: string
}

export const podcastItunesTypeDefaultValue = 'episodic'

@Index(['hasVideo', 'pastAllTimeTotalUniquePageviews'])
@Index(['hasVideo', 'pastHourTotalUniquePageviews'])
@Index(['hasVideo', 'pastDayTotalUniquePageviews'])
Expand Down Expand Up @@ -248,7 +227,7 @@ export class Podcast {
type?: string

@Column('simple-json', { nullable: true })
value: Value[]
value: ValueTagOriginal[]

@ManyToMany((type) => Author, (author) => author.podcasts)
@JoinTable()
Expand Down
15 changes: 15 additions & 0 deletions src/routes/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@ router.get('/min-mobile-version', async (ctx) => {
}
})

router.get('/app-info', async (ctx) => {
const { minimumMobileVersion, maintenanceMode } = config
try {
ctx.body = {
version: minimumMobileVersion,
maintenanceScheduled: {
endTime: maintenanceMode?.scheduled?.endTime,
startTime: maintenanceMode?.scheduled?.startTime
}
}
} catch (error) {
emitRouterError(error, ctx)
}
})

export const metaRouter = router
8 changes: 4 additions & 4 deletions src/services/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
Funding,
ParsedEpisode,
parseLatestLiveItemStatus,
parseLatestLiveItemInfo
parseLatestLiveItemInfo,
ValueTagOriginal,
podcastItunesTypeDefaultValue
} from 'podverse-shared'
import { getRepository, In, Not } from 'typeorm'
import { config } from '~/config'
import { updateSoundBites } from '~/controllers/mediaRef'
import { getPodcast } from '~/controllers/podcast'
import { Author, Category, Episode, FeedUrl, LiveItem, Podcast } from '~/entities'
import { podcastItunesTypeDefaultValue } from '~/entities/podcast'
import type { Value } from '~/entities/podcast'
import {
_logEnd,
_logStart,
Expand Down Expand Up @@ -163,7 +163,7 @@ export const parseFeedUrl = async (feedUrl, forceReparsing = false, cacheBust =
}
}

const valueCompat = (val: Phase4Value): Value => {
const valueCompat = (val: Phase4Value): ValueTagOriginal => {
return {
type: val.type,
method: val.method,
Expand Down
6 changes: 3 additions & 3 deletions src/services/podcastIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { addFeedUrlsByPodcastIndexId } from '~/services/queue'
import { request } from '~/lib/request'
import { getPodcastByPodcastIndexId } from '~/controllers/podcast'
import { Podcast } from '~/entities'
import { ValueTag } from 'podverse-shared'
import { ValueTagOriginal } from 'podverse-shared'
const shortid = require('shortid')
const sha1 = require('crypto-js/sha1')
const encHex = require('crypto-js/enc-hex')
Expand Down Expand Up @@ -228,7 +228,7 @@ export const getPodcastFromPodcastIndexByGuid = async (podcastGuid: string) => {
// (usually a song) is playing right now.
export const getValueTagForChannelFromPodcastIndexByGuids = async (podcastGuid: string) => {
const url = `${podcastIndexConfig.baseUrl}/podcasts/byguid?guid=${podcastGuid}`
let podcastValueTag: ValueTag[] | null = null
let podcastValueTag: ValueTagOriginal[] | null = null

try {
const response = await axiosRequest(url)
Expand All @@ -253,7 +253,7 @@ export const getValueTagForItemFromPodcastIndexByGuids = async (podcastGuid: str
episodeGuid = encodeURIComponent(episodeGuid)
}
const url = `${podcastIndexConfig.baseUrl}/episodes/byguid?podcastguid=${podcastGuid}&guid=${episodeGuid}`
let episodeValueTag: ValueTag[] | null = null
let episodeValueTag: ValueTagOriginal[] | null = null

try {
const response = await axiosRequest(url)
Expand Down
2 changes: 1 addition & 1 deletion src/services/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const queryUniquePageviews = async (pagePath: string, timeRange) => {
*/

const filterCustomFeedUrls = (data: any[], limit: number) => {
return data.filter((x) => x.url.length <= limit)
return data.filter((x) => x.url.length <= limit && x.url?.split('/').length - 1 === 4)
}

const podcastLimit = 42 // https://podverse.fm/podcast/12345678901234
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8200,10 +8200,10 @@ [email protected]:
ramda "^0.27.1"
tiny-invariant "^1.2.0"

podverse-shared@^4.14.15:
version "4.14.15"
resolved "https://registry.yarnpkg.com/podverse-shared/-/podverse-shared-4.14.15.tgz#c6a9ce60a0e4a5c03ccabf4e9fe0949b1d1a2682"
integrity sha512-aZ6x8DzB9wvLRBgRP8X+/4zoLRG/p3eoEyjJ1wOQhPAVKbPN2q1E/nQ55bHkdFQP+wLcAdGDZ8JPpyvIXIEpug==
podverse-shared@4.15.2:
version "4.15.2"
resolved "https://registry.yarnpkg.com/podverse-shared/-/podverse-shared-4.15.2.tgz#ef2a9ae3845ca9833f62972428ab058511bc195a"
integrity sha512-X9jtauggsxazN4F00PkQONiK3DT345v7qL4SXpQh+Qz+1zY5dfJbTBN4fcfya4xp5L1BPpsAj6mn6ALx+ravCQ==
dependencies:
"@types/lodash" "4.14.172"
he "^1.2.0"
Expand Down

0 comments on commit 78892c9

Please sign in to comment.