Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gab-social
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
gab
social
gab-social
Commits
7219c9b5
Commit
7219c9b5
authored
Sep 17, 2019
by
2458773093
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service + seerializer completed
parent
cdc0b8dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
app/serializers/rest/status_serializer.rb
app/serializers/rest/status_serializer.rb
+1
-1
app/services/edit_status_service.rb
app/services/edit_status_service.rb
+22
-0
No files found.
app/serializers/rest/status_serializer.rb
View file @
7219c9b5
# frozen_string_literal: true
class
REST::StatusSerializer
<
ActiveModel
::
Serializer
attributes
:id
,
:created_at
,
:in_reply_to_id
,
:in_reply_to_account_id
,
attributes
:id
,
:created_at
,
:
revised_at
,
:
in_reply_to_id
,
:in_reply_to_account_id
,
:sensitive
,
:spoiler_text
,
:visibility
,
:language
,
:uri
,
:url
,
:replies_count
,
:reblogs_count
,
:favourites_count
,
:quote_of_id
...
...
app/services/edit_status_service.rb
View file @
7219c9b5
...
...
@@ -25,9 +25,11 @@ class EditStatusService < BaseService
validate_media!
preprocess_attributes!
revision_text
=
prepare_revision_text
process_status!
postprocess_status!
create_revision!
revision_text
redis
.
setex
(
idempotency_key
,
3_600
,
@status
.
id
)
if
idempotency_given?
...
...
@@ -60,6 +62,25 @@ class EditStatusService < BaseService
LinkCrawlWorker
.
perform_async
(
@status
.
id
)
unless
@status
.
spoiler_text?
end
def
prepare_revision_text
text
=
@status
.
text
current_media_ids
=
@status
.
media_attachments
.
pluck
(
:id
)
new_media_ids
=
@options
[
:media_ids
].
take
(
4
).
map
(
&
:to_i
)
if
current_media_ids
.
sort
!=
new_media_ids
.
sort
text
=
""
if
text
==
@options
[
:text
]
text
+=
" [Media attachments changed]"
end
text
.
strip
()
end
def
create_revision!
(
text
)
@status
.
revisions
.
create!
({
text:
text
})
end
def
validate_media!
return
if
@options
[
:media_ids
].
blank?
||
!
@options
[
:media_ids
].
is_a?
(
Enumerable
)
...
...
@@ -100,6 +121,7 @@ class EditStatusService < BaseService
def
status_attributes
{
revised_at:
Time
.
now
,
text:
@text
,
media_attachments:
@media
||
[],
sensitive:
(
@options
[
:sensitive
].
nil?
?
@account
.
user
&
.
setting_default_sensitive
:
@options
[
:sensitive
])
||
@options
[
:spoiler_text
].
present?
,
...
...
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