Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dima Krasner
Sharkey
Commits
04c8a707
Commit
04c8a707
authored
1 year ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
fix of
8c684d53
parent
6d5e18aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/backend/src/server/api/endpoints/users/notes.ts
+28
-31
28 additions, 31 deletions
packages/backend/src/server/api/endpoints/users/notes.ts
with
28 additions
and
31 deletions
packages/backend/src/server/api/endpoints/users/notes.ts
+
28
−
31
View file @
04c8a707
...
...
@@ -78,8 +78,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this
.
cacheService
.
userMutingsCache
.
fetch
(
me
.
id
),
])
:
[
new
Set
<
string
>
()];
let
timeline
:
MiNote
[]
=
[];
const
limit
=
ps
.
limit
+
(
ps
.
untilId
?
1
:
0
)
+
(
ps
.
sinceId
?
1
:
0
);
// untilIdに指定したものも含まれるため+1
const
[
noteIdsRes
,
repliesNoteIdsRes
,
channelNoteIdsRes
]
=
await
Promise
.
all
([
...
...
@@ -115,41 +113,40 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
noteIds
.
sort
((
a
,
b
)
=>
a
>
b
?
-
1
:
1
);
noteIds
=
noteIds
.
slice
(
0
,
ps
.
limit
);
if
(
noteIds
.
length
===
0
)
{
return
[];
}
const
isFollowing
=
me
?
Object
.
hasOwn
(
await
this
.
cacheService
.
userFollowingsCache
.
fetch
(
me
.
id
),
ps
.
userId
)
:
false
;
if
(
noteIds
.
length
>
0
)
{
const
isFollowing
=
me
?
Object
.
hasOwn
(
await
this
.
cacheService
.
userFollowingsCache
.
fetch
(
me
.
id
),
ps
.
userId
)
:
false
;
const
query
=
this
.
notesRepository
.
createQueryBuilder
(
'
note
'
)
.
where
(
'
note.id IN (:...noteIds)
'
,
{
noteIds
:
noteIds
})
.
innerJoinAndSelect
(
'
note.user
'
,
'
user
'
)
.
leftJoinAndSelect
(
'
note.reply
'
,
'
reply
'
)
.
leftJoinAndSelect
(
'
note.renote
'
,
'
renote
'
)
.
leftJoinAndSelect
(
'
reply.user
'
,
'
replyUser
'
)
.
leftJoinAndSelect
(
'
renote.user
'
,
'
renoteUser
'
)
.
leftJoinAndSelect
(
'
note.channel
'
,
'
channel
'
);
const
query
=
this
.
notesRepository
.
createQueryBuilder
(
'
note
'
)
.
where
(
'
note.id IN (:...noteIds)
'
,
{
noteIds
:
noteIds
})
.
innerJoinAndSelect
(
'
note.user
'
,
'
user
'
)
.
leftJoinAndSelect
(
'
note.reply
'
,
'
reply
'
)
.
leftJoinAndSelect
(
'
note.renote
'
,
'
renote
'
)
.
leftJoinAndSelect
(
'
reply.user
'
,
'
replyUser
'
)
.
leftJoinAndSelect
(
'
renote.user
'
,
'
renoteUser
'
)
.
leftJoinAndSelect
(
'
note.channel
'
,
'
channel
'
);
timeline
=
await
query
.
getMany
();
let
timeline
=
await
query
.
getMany
();
timeline
=
timeline
.
filter
(
note
=>
{
if
(
me
&&
isUserRelated
(
note
,
userIdsWhoMeMuting
,
true
))
return
false
;
timeline
=
timeline
.
filter
(
note
=>
{
if
(
me
&&
isUserRelated
(
note
,
userIdsWhoMeMuting
,
true
))
return
false
;
if
(
note
.
renoteId
)
{
if
(
note
.
text
==
null
&&
note
.
fileIds
.
length
===
0
&&
!
note
.
hasPoll
)
{
if
(
ps
.
withRenotes
===
false
)
return
false
;
if
(
note
.
renoteId
)
{
if
(
note
.
text
==
null
&&
note
.
fileIds
.
length
===
0
&&
!
note
.
hasPoll
)
{
if
(
ps
.
withRenotes
===
false
)
return
false
;
}
}
}
if
(
note
.
visibility
===
'
followers
'
&&
!
isFollowing
)
return
false
;
if
(
note
.
visibility
===
'
followers
'
&&
!
isFollowing
)
return
false
;
return
true
;
});
return
true
;
});
timeline
.
sort
((
a
,
b
)
=>
a
.
id
>
b
.
id
?
-
1
:
1
);
timeline
.
sort
((
a
,
b
)
=>
a
.
id
>
b
.
id
?
-
1
:
1
);
return
await
this
.
noteEntityService
.
packMany
(
timeline
,
me
);
}
else
{
// fallback to database
// fallback to database
if
(
timeline
.
length
===
0
)
{
//#region Construct query
const
query
=
this
.
queryService
.
makePaginationQuery
(
this
.
notesRepository
.
createQueryBuilder
(
'
note
'
),
ps
.
sinceId
,
ps
.
untilId
,
ps
.
sinceDate
,
ps
.
untilDate
)
.
andWhere
(
'
note.userId = :userId
'
,
{
userId
:
ps
.
userId
})
...
...
@@ -182,10 +179,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
//#endregion
timeline
=
await
query
.
limit
(
ps
.
limit
).
getMany
();
}
const
timeline
=
await
query
.
limit
(
ps
.
limit
).
getMany
();
return
await
this
.
noteEntityService
.
packMany
(
timeline
,
me
);
return
await
this
.
noteEntityService
.
packMany
(
timeline
,
me
);
}
});
}
}
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