Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mastodon
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chameleoid
AWOO.pub
mastodon
Commits
e2a5be6e
Commit
e2a5be6e
authored
Jan 26, 2019
by
ThibG
Committed by
Eugen Rochko
Jan 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent posting toots with media attachments from someone else (#9921)
parent
9519d553
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
post_status_service.rb
app/services/post_status_service.rb
+1
-1
post_status_service_spec.rb
spec/services/post_status_service_spec.rb
+14
-1
No files found.
app/services/post_status_service.rb
View file @
e2a5be6e
...
...
@@ -93,7 +93,7 @@ class PostStatusService < BaseService
raise
Mastodon
::
ValidationError
,
I18n
.
t
(
'media_attachments.validations.too_many'
)
if
@options
[
:media_ids
].
size
>
4
@media
=
MediaAttachment
.
where
(
status_id:
nil
).
where
(
id:
@options
[
:media_ids
].
take
(
4
).
map
(
&
:to_i
))
@media
=
@account
.
media_attachments
.
where
(
status_id:
nil
).
where
(
id:
@options
[
:media_ids
].
take
(
4
).
map
(
&
:to_i
))
raise
Mastodon
::
ValidationError
,
I18n
.
t
(
'media_attachments.validations.images_and_video'
)
if
@media
.
size
>
1
&&
@media
.
find
(
&
:video?
)
end
...
...
spec/services/post_status_service_spec.rb
View file @
e2a5be6e
...
...
@@ -167,7 +167,7 @@ RSpec.describe PostStatusService, type: :service do
it
'attaches the given media to the created status'
do
account
=
Fabricate
(
:account
)
media
=
Fabricate
(
:media_attachment
)
media
=
Fabricate
(
:media_attachment
,
account:
account
)
status
=
subject
.
call
(
account
,
...
...
@@ -178,6 +178,19 @@ RSpec.describe PostStatusService, type: :service do
expect
(
media
.
reload
.
status
).
to
eq
status
end
it
'does not attach media from another account to the created status'
do
account
=
Fabricate
(
:account
)
media
=
Fabricate
(
:media_attachment
,
account:
Fabricate
(
:account
))
status
=
subject
.
call
(
account
,
text:
"test status update"
,
media_ids:
[
media
.
id
],
)
expect
(
media
.
reload
.
status
).
to
eq
nil
end
it
'does not allow attaching more than 4 files'
do
account
=
Fabricate
(
:account
)
...
...
Write
Preview
Markdown
is supported
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