Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
5a9a56b7
Verified
Commit
5a9a56b7
authored
Jul 29, 2022
by
Chocobozzz
Browse files
Prevent error on highlighted thread
parent
37b1d97f
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts
View file @
5a9a56b7
...
...
@@ -5,6 +5,7 @@ import { AuthService, ComponentPagination, ConfirmService, hasMoreItems, Notifie
import
{
HooksService
}
from
'
@app/core/plugins/hooks.service
'
import
{
Syndication
,
VideoDetails
}
from
'
@app/shared/shared-main
'
import
{
VideoComment
,
VideoCommentService
,
VideoCommentThreadTree
}
from
'
@app/shared/shared-video-comment
'
import
{
PeerTubeProblemDocument
,
ServerErrorCode
}
from
'
@shared/models
'
@
Component
({
selector
:
'
my-video-comments
'
,
...
...
@@ -104,7 +105,14 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
}
},
error
:
err
=>
this
.
notifier
.
error
(
err
.
message
)
error
:
err
=>
{
// We may try to fetch highlighted thread of another video, skip the error if it is the case
// We'll retry the request on video Input() change
const
errorBody
=
err
.
body
as
PeerTubeProblemDocument
if
(
highlightThread
&&
errorBody
?.
code
===
ServerErrorCode
.
COMMENT_NOT_ASSOCIATED_TO_VIDEO
)
return
this
.
notifier
.
error
(
err
.
message
)
}
})
}
...
...
@@ -254,6 +262,10 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
this
.
syndicationItems
=
this
.
videoCommentService
.
getVideoCommentsFeeds
(
this
.
video
)
this
.
loadMoreThreads
()
if
(
this
.
activatedRoute
.
params
[
'
threadId
'
])
{
this
.
processHighlightedThread
(
+
this
.
activatedRoute
.
params
[
'
threadId
'
])
}
}
}
...
...
client/src/app/+videos/+video-watch/video-watch.component.ts
View file @
5a9a56b7
...
...
@@ -242,6 +242,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
if
(
this
.
player
)
this
.
player
.
pause
()
this
.
video
=
undefined
const
videoObs
=
this
.
hooks
.
wrapObsFun
(
this
.
videoService
.
getVideo
.
bind
(
this
.
videoService
),
{
videoId
},
...
...
server/middlewares/validators/shared/video-comments.ts
View file @
5a9a56b7
import
express
from
'
express
'
import
{
VideoCommentModel
}
from
'
@server/models/video/video-comment
'
import
{
MVideoId
}
from
'
@server/types/models
'
import
{
HttpStatusCode
}
from
'
@shared/models
'
import
{
HttpStatusCode
,
ServerErrorCode
}
from
'
@shared/models
'
async
function
doesVideoCommentThreadExist
(
idArg
:
number
|
string
,
video
:
MVideoId
,
res
:
express
.
Response
)
{
const
id
=
parseInt
(
idArg
+
''
,
10
)
...
...
@@ -16,7 +16,10 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide
}
if
(
videoComment
.
videoId
!==
video
.
id
)
{
res
.
fail
({
message
:
'
Video comment is not associated to this video.
'
})
res
.
fail
({
type
:
ServerErrorCode
.
COMMENT_NOT_ASSOCIATED_TO_VIDEO
,
message
:
'
Video comment is not associated to this video.
'
})
return
false
}
...
...
@@ -42,7 +45,10 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r
}
if
(
videoComment
.
videoId
!==
video
.
id
)
{
res
.
fail
({
message
:
'
Video comment is not associated to this video.
'
})
res
.
fail
({
type
:
ServerErrorCode
.
COMMENT_NOT_ASSOCIATED_TO_VIDEO
,
message
:
'
Video comment is not associated to this video.
'
})
return
false
}
...
...
shared/models/server/server-error-code.enum.ts
View file @
5a9a56b7
...
...
@@ -37,7 +37,9 @@ export const enum ServerErrorCode {
* A torrent should have at most one correct video file. Any more and we will
* not be able to choose automatically.
*/
INCORRECT_FILES_IN_TORRENT
=
'
incorrect_files_in_torrent
'
INCORRECT_FILES_IN_TORRENT
=
'
incorrect_files_in_torrent
'
,
COMMENT_NOT_ASSOCIATED_TO_VIDEO
=
'
comment_not_associated_to_video
'
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment