Skip to content

Commit e402c42

Browse files
authored
feat: issues (sct#2180)
1 parent 6565c7d commit e402c42

File tree

45 files changed

+4157
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4157
-834
lines changed

overseerr-api.yml

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,36 @@ components:
16871687
type: number
16881688
name:
16891689
type: string
1690+
Issue:
1691+
type: object
1692+
properties:
1693+
id:
1694+
type: number
1695+
example: 1
1696+
issueType:
1697+
type: number
1698+
example: 1
1699+
media:
1700+
$ref: '#/components/schemas/MediaInfo'
1701+
createdBy:
1702+
$ref: '#/components/schemas/User'
1703+
modifiedBy:
1704+
$ref: '#/components/schemas/User'
1705+
comments:
1706+
type: array
1707+
items:
1708+
$ref: '#/components/schemas/IssueComment'
1709+
IssueComment:
1710+
type: object
1711+
properties:
1712+
id:
1713+
type: number
1714+
example: 1
1715+
user:
1716+
$ref: '#/components/schemas/User'
1717+
message:
1718+
type: string
1719+
example: A comment
16901720
securitySchemes:
16911721
cookieAuth:
16921722
type: apiKey
@@ -5183,7 +5213,251 @@ paths:
51835213
type: array
51845214
items:
51855215
type: string
5216+
/issue:
5217+
get:
5218+
summary: Get all issues
5219+
description: |
5220+
Returns a list of issues in JSON format.
5221+
tags:
5222+
- issue
5223+
parameters:
5224+
- in: query
5225+
name: take
5226+
schema:
5227+
type: number
5228+
nullable: true
5229+
example: 20
5230+
- in: query
5231+
name: skip
5232+
schema:
5233+
type: number
5234+
nullable: true
5235+
example: 0
5236+
- in: query
5237+
name: sort
5238+
schema:
5239+
type: string
5240+
enum: [added, modified]
5241+
default: added
5242+
- in: query
5243+
name: filter
5244+
schema:
5245+
type: string
5246+
enum: [all, open, resolved]
5247+
default: open
5248+
- in: query
5249+
name: requestedBy
5250+
schema:
5251+
type: number
5252+
nullable: true
5253+
example: 1
5254+
responses:
5255+
'200':
5256+
description: Issues returned
5257+
content:
5258+
application/json:
5259+
schema:
5260+
type: object
5261+
properties:
5262+
pageInfo:
5263+
$ref: '#/components/schemas/PageInfo'
5264+
results:
5265+
type: array
5266+
items:
5267+
$ref: '#/components/schemas/Issue'
5268+
post:
5269+
summary: Create new issue
5270+
description: |
5271+
Creates a new issue
5272+
tags:
5273+
- issue
5274+
requestBody:
5275+
required: true
5276+
content:
5277+
application/json:
5278+
schema:
5279+
type: object
5280+
properties:
5281+
issueType:
5282+
type: number
5283+
message:
5284+
type: string
5285+
mediaId:
5286+
type: number
5287+
responses:
5288+
'201':
5289+
description: Succesfully created the issue
5290+
content:
5291+
application/json:
5292+
schema:
5293+
$ref: '#/components/schemas/Issue'
5294+
/issue/{issueId}:
5295+
get:
5296+
summary: Get issue
5297+
description: |
5298+
Returns a single issue in JSON format.
5299+
tags:
5300+
- issue
5301+
parameters:
5302+
- in: path
5303+
name: issueId
5304+
required: true
5305+
schema:
5306+
type: number
5307+
example: 1
5308+
responses:
5309+
'200':
5310+
description: Issues returned
5311+
content:
5312+
application/json:
5313+
schema:
5314+
$ref: '#/components/schemas/Issue'
5315+
delete:
5316+
summary: Delete issue
5317+
description: Removes an issue. If the user has the `MANAGE_ISSUES` permission, any issue can be removed. Otherwise, only a users own issues can be removed.
5318+
tags:
5319+
- issue
5320+
parameters:
5321+
- in: path
5322+
name: issueId
5323+
description: Issue ID
5324+
required: true
5325+
example: '1'
5326+
schema:
5327+
type: string
5328+
responses:
5329+
'204':
5330+
description: Succesfully removed issue
5331+
/issue/{issueId}/comment:
5332+
post:
5333+
summary: Create a comment
5334+
description: |
5335+
Creates a comment and returns associated issue in JSON format.
5336+
tags:
5337+
- issue
5338+
parameters:
5339+
- in: path
5340+
name: issueId
5341+
required: true
5342+
schema:
5343+
type: number
5344+
example: 1
5345+
requestBody:
5346+
required: true
5347+
content:
5348+
application/json:
5349+
schema:
5350+
type: object
5351+
properties:
5352+
message:
5353+
type: string
5354+
required:
5355+
- message
5356+
responses:
5357+
'200':
5358+
description: Issue returned with new comment
5359+
content:
5360+
application/json:
5361+
schema:
5362+
$ref: '#/components/schemas/Issue'
5363+
/issueComment/{commentId}:
5364+
get:
5365+
summary: Get issue comment
5366+
description: |
5367+
Returns a single issue comment in JSON format.
5368+
tags:
5369+
- issue
5370+
parameters:
5371+
- in: path
5372+
name: commentId
5373+
required: true
5374+
schema:
5375+
type: string
5376+
example: 1
5377+
responses:
5378+
'200':
5379+
description: Comment returned
5380+
content:
5381+
application/json:
5382+
schema:
5383+
$ref: '#/components/schemas/IssueComment'
5384+
put:
5385+
summary: Update issue comment
5386+
description: |
5387+
Updates and returns a single issue comment in JSON format.
5388+
tags:
5389+
- issue
5390+
parameters:
5391+
- in: path
5392+
name: commentId
5393+
required: true
5394+
schema:
5395+
type: string
5396+
example: 1
5397+
requestBody:
5398+
required: true
5399+
content:
5400+
application/json:
5401+
schema:
5402+
type: object
5403+
properties:
5404+
message:
5405+
type: string
5406+
responses:
5407+
'200':
5408+
description: Comment updated
5409+
content:
5410+
application/json:
5411+
schema:
5412+
$ref: '#/components/schemas/IssueComment'
5413+
delete:
5414+
summary: Delete issue comment
5415+
description: |
5416+
Deletes an issue comment. Only users with `MANAGE_ISSUES` or the user who created the comment can perform this action.
5417+
tags:
5418+
- issue
5419+
parameters:
5420+
- in: path
5421+
name: commentId
5422+
description: Issue Comment ID
5423+
required: true
5424+
example: '1'
5425+
schema:
5426+
type: string
5427+
responses:
5428+
'204':
5429+
description: Succesfully removed issue comment
5430+
/issue/{issueId}/{status}:
5431+
post:
5432+
summary: Update an issue's status
5433+
description: |
5434+
Updates an issue's status to approved or declined. Also returns the issue in a JSON object.
51865435
5436+
Requires the `MANAGE_ISSUES` permission or `ADMIN`.
5437+
tags:
5438+
- issue
5439+
parameters:
5440+
- in: path
5441+
name: issueId
5442+
description: Issue ID
5443+
required: true
5444+
schema:
5445+
type: string
5446+
example: '1'
5447+
- in: path
5448+
name: status
5449+
description: New status
5450+
required: true
5451+
schema:
5452+
type: string
5453+
enum: [open, resolved]
5454+
responses:
5455+
'200':
5456+
description: Issue status changed
5457+
content:
5458+
application/json:
5459+
schema:
5460+
$ref: '#/components/schemas/Issue'
51875461
security:
51885462
- cookieAuth: []
51895463
- apiKey: []

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"migration:run": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:run",
1616
"format": "prettier --write ."
1717
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/sct/overseerr.git"
21+
},
1822
"license": "MIT",
1923
"dependencies": {
2024
"@headlessui/react": "^1.4.1",

server/constants/issue.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export enum IssueType {
2+
VIDEO = 1,
3+
AUDIO = 2,
4+
SUBTITLES = 3,
5+
OTHER = 4,
6+
}
7+
8+
export enum IssueStatus {
9+
OPEN = 1,
10+
RESOLVED = 2,
11+
}
12+
13+
export const IssueTypeNames = {
14+
[IssueType.AUDIO]: 'Audio',
15+
[IssueType.VIDEO]: 'Video',
16+
[IssueType.SUBTITLES]: 'Subtitles',
17+
[IssueType.OTHER]: 'Other',
18+
};

server/entity/Issue.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import {
2+
Column,
3+
CreateDateColumn,
4+
Entity,
5+
ManyToOne,
6+
OneToMany,
7+
PrimaryGeneratedColumn,
8+
UpdateDateColumn,
9+
} from 'typeorm';
10+
import { IssueStatus, IssueType } from '../constants/issue';
11+
import IssueComment from './IssueComment';
12+
import Media from './Media';
13+
import { User } from './User';
14+
15+
@Entity()
16+
class Issue {
17+
@PrimaryGeneratedColumn()
18+
public id: number;
19+
20+
@Column({ type: 'int' })
21+
public issueType: IssueType;
22+
23+
@Column({ type: 'int', default: IssueStatus.OPEN })
24+
public status: IssueStatus;
25+
26+
@Column({ type: 'int', default: 0 })
27+
public problemSeason: number;
28+
29+
@Column({ type: 'int', default: 0 })
30+
public problemEpisode: number;
31+
32+
@ManyToOne(() => Media, (media) => media.issues, {
33+
eager: true,
34+
onDelete: 'CASCADE',
35+
})
36+
public media: Media;
37+
38+
@ManyToOne(() => User, (user) => user.createdIssues, {
39+
eager: true,
40+
onDelete: 'CASCADE',
41+
})
42+
public createdBy: User;
43+
44+
@ManyToOne(() => User, {
45+
eager: true,
46+
onDelete: 'CASCADE',
47+
nullable: true,
48+
})
49+
public modifiedBy?: User;
50+
51+
@OneToMany(() => IssueComment, (comment) => comment.issue, {
52+
cascade: true,
53+
eager: true,
54+
})
55+
public comments: IssueComment[];
56+
57+
@CreateDateColumn()
58+
public createdAt: Date;
59+
60+
@UpdateDateColumn()
61+
public updatedAt: Date;
62+
63+
constructor(init?: Partial<Issue>) {
64+
Object.assign(this, init);
65+
}
66+
}
67+
68+
export default Issue;

0 commit comments

Comments
 (0)