Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
ebfeaebe
Unverified
Commit
ebfeaebe
authored
1 year ago
by
Claire
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix /api/v1/conversations sometimes returning empty accounts (#25499)
parent
ec91ea44
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/account_conversation.rb
+2
-8
2 additions, 8 deletions
app/models/account_conversation.rb
spec/controllers/api/v1/conversations_controller_spec.rb
+4
-2
4 additions, 2 deletions
spec/controllers/api/v1/conversations_controller_spec.rb
with
6 additions
and
10 deletions
app/models/account_conversation.rb
+
2
−
8
View file @
ebfeaebe
...
...
@@ -32,14 +32,8 @@ class AccountConversation < ApplicationRecord
end
def
participant_accounts
@participant_accounts
||=
begin
if
participant_account_ids
.
empty?
[
account
]
else
participants
=
Account
.
where
(
id:
participant_account_ids
).
to_a
participants
.
empty?
?
[
account
]
:
participants
end
end
@participant_accounts
||=
Account
.
where
(
id:
participant_account_ids
).
to_a
@participant_accounts
.
presence
||
[
account
]
end
class
<<
self
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/api/v1/conversations_controller_spec.rb
+
4
−
2
View file @
ebfeaebe
...
...
@@ -18,6 +18,7 @@ RSpec.describe Api::V1::ConversationsController do
before
do
PostStatusService
.
new
.
call
(
other
.
account
,
text:
'Hey @alice'
,
visibility:
'direct'
)
PostStatusService
.
new
.
call
(
user
.
account
,
text:
'Hey, nobody here'
,
visibility:
'direct'
)
end
it
'returns http success'
do
...
...
@@ -33,7 +34,8 @@ RSpec.describe Api::V1::ConversationsController do
it
'returns conversations'
do
get
:index
json
=
body_as_json
expect
(
json
.
size
).
to
eq
1
expect
(
json
.
size
).
to
eq
2
expect
(
json
[
0
][
:accounts
].
size
).
to
eq
1
end
context
'with since_id'
do
...
...
@@ -41,7 +43,7 @@ RSpec.describe Api::V1::ConversationsController do
it
'returns conversations'
do
get
:index
,
params:
{
since_id:
Mastodon
::
Snowflake
.
id_at
(
1
.
hour
.
ago
,
with_random:
false
)
}
json
=
body_as_json
expect
(
json
.
size
).
to
eq
1
expect
(
json
.
size
).
to
eq
2
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment