Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
25843710
Commit
25843710
authored
2 years ago
by
Eugen Rochko
Browse files
Options
Download
Email Patches
Plain Diff
Fix error when response contains reblogs of soft-deleted statuses in REST API
parent
f6d35ed5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/status.rb
+7
-11
app/models/status.rb
app/presenters/status_relationships_presenter.rb
+1
-1
app/presenters/status_relationships_presenter.rb
with
8 additions
and
12 deletions
+8
-12
app/models/status.rb
+
7
-
11
View file @
25843710
...
...
@@ -336,22 +336,18 @@ class Status < ApplicationRecord
end
def
reload_stale_associations!
(
cached_items
)
account_ids
=
[]
cached_items
.
each
do
|
item
|
account_ids
<<
item
.
account_id
account_ids
<<
item
.
reblog
.
account_id
if
item
.
reblog?
end
account_ids
.
uniq!
account_ids
=
cached_items
.
each_with_object
([])
do
|
item
,
arr
|
arr
<<
item
.
account_id
arr
<<
item
.
reblog
&
.
account_id
if
item
.
reblog?
end
.
compact
.
uniq
return
if
account_ids
.
empty?
accounts
=
Account
.
where
(
id:
account_ids
).
includes
(
:account_stat
,
:user
).
index_by
(
&
:id
)
accounts
_map
=
Account
.
where
(
id:
account_ids
).
includes
(
:account_stat
,
:user
).
index_by
(
&
:id
)
cached_items
.
each
do
|
item
|
item
.
account
=
accounts
[
item
.
account_id
]
item
.
reblog
.
account
=
accounts
[
item
.
reblog
.
account_id
]
if
item
.
reblog?
item
.
account
=
accounts
_map
[
item
.
account_id
]
item
.
reblog
.
account
=
accounts
_map
[
item
.
reblog
.
account_id
]
if
item
.
reblog?
&&
item
.
reblog
end
end
...
...
This diff is collapsed.
Click to expand it.
app/presenters/status_relationships_presenter.rb
+
1
-
1
View file @
25843710
...
...
@@ -15,7 +15,7 @@ class StatusRelationshipsPresenter
statuses
=
statuses
.
compact
status_ids
=
statuses
.
flat_map
{
|
s
|
[
s
.
id
,
s
.
reblog_of_id
]
}.
uniq
.
compact
conversation_ids
=
statuses
.
filter_map
(
&
:conversation_id
).
uniq
pinnable_status_ids
=
statuses
.
map
(
&
:proper
).
filter_map
{
|
s
|
s
.
id
if
s
.
account_id
==
current_account_id
&&
%w(public unlisted private)
.
include?
(
s
.
visibility
)
}
pinnable_status_ids
=
statuses
.
filter_
map
(
&
:proper
).
filter_map
{
|
s
|
s
.
id
if
s
.
account_id
==
current_account_id
&&
%w(public unlisted private)
.
include?
(
s
.
visibility
)
}
@reblogs_map
=
Status
.
reblogs_map
(
status_ids
,
current_account_id
).
merge
(
options
[
:reblogs_map
]
||
{})
@favourites_map
=
Status
.
favourites_map
(
status_ids
,
current_account_id
).
merge
(
options
[
:favourites_map
]
||
{})
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets