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
1cd8bfad
Commit
1cd8bfad
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
fix(server): ノート翻訳時に公開範囲が考慮されていない問題を修正
parent
65d9c304
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+6
-0
6 additions, 0 deletions
CHANGELOG.md
src/models/repositories/note.ts
+50
-0
50 additions, 0 deletions
src/models/repositories/note.ts
src/server/api/endpoints/notes/translate.ts
+5
-0
5 additions, 0 deletions
src/server/api/endpoints/notes/translate.ts
with
61 additions
and
0 deletions
CHANGELOG.md
+
6
−
0
View file @
1cd8bfad
...
...
@@ -7,6 +7,12 @@
-->
## 12.x.x (unreleased)
### Bugfixes
-
Dockerfileを修正
-
ノート翻訳時に公開範囲が考慮されていない問題を修正
## 12.90.0 (2021/09/04)
### Improvements
...
...
This diff is collapsed.
Click to expand it.
src/models/repositories/note.ts
+
50
−
0
View file @
1cd8bfad
...
...
@@ -18,7 +18,57 @@ export class NoteRepository extends Repository<Note> {
return
x
.
trim
().
length
<=
100
;
}
public
async
isVisibleForMe
(
note
:
Note
,
meId
:
User
[
'
id
'
]
|
null
):
Promise
<
boolean
>
{
// visibility が specified かつ自分が指定されていなかったら非表示
if
(
note
.
visibility
===
'
specified
'
)
{
if
(
meId
==
null
)
{
return
false
;
}
else
if
(
meId
===
note
.
userId
)
{
return
true
;
}
else
{
// 指定されているかどうか
const
specified
=
note
.
visibleUserIds
.
some
((
id
:
any
)
=>
meId
===
id
);
if
(
specified
)
{
return
true
;
}
else
{
return
false
;
}
}
}
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
if
(
note
.
visibility
===
'
followers
'
)
{
if
(
meId
==
null
)
{
return
false
;
}
else
if
(
meId
===
note
.
userId
)
{
return
true
;
}
else
if
(
note
.
reply
&&
(
meId
===
note
.
reply
.
userId
))
{
// 自分の投稿に対するリプライ
return
true
;
}
else
if
(
note
.
mentions
&&
note
.
mentions
.
some
(
id
=>
meId
===
id
))
{
// 自分へのメンション
return
true
;
}
else
{
// フォロワーかどうか
const
following
=
await
Followings
.
findOne
({
followeeId
:
note
.
userId
,
followerId
:
meId
});
if
(
following
==
null
)
{
return
false
;
}
else
{
return
true
;
}
}
}
return
true
;
}
private
async
hideNote
(
packedNote
:
PackedNote
,
meId
:
User
[
'
id
'
]
|
null
)
{
// TODO: isVisibleForMe を使うようにしても良さそう(型違うけど)
let
hide
=
false
;
// visibility が specified かつ自分が指定されていなかったら非表示
...
...
This diff is collapsed.
Click to expand it.
src/server/api/endpoints/notes/translate.ts
+
5
−
0
View file @
1cd8bfad
...
...
@@ -8,6 +8,7 @@ import config from '@/config/index';
import
{
getAgentByUrl
}
from
'
@/misc/fetch
'
;
import
{
URLSearchParams
}
from
'
url
'
;
import
{
fetchMeta
}
from
'
@/misc/fetch-meta
'
;
import
{
Notes
}
from
'
@/models
'
;
export
const
meta
=
{
tags
:
[
'
notes
'
],
...
...
@@ -43,6 +44,10 @@ export default define(meta, async (ps, user) => {
throw
e
;
});
if
(
!
(
await
Notes
.
isVisibleForMe
(
note
,
user
?
user
.
id
:
null
)))
{
return
204
;
// TODO: 良い感じのエラー返す
}
if
(
note
.
text
==
null
)
{
return
204
;
}
...
...
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