Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
339
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
24
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
TransFem.org
Sharkey
Commits
6575a6de
Commit
6575a6de
authored
7 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
34923888
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
src/api/endpoints/i/notifications.ts
+18
-5
18 additions, 5 deletions
src/api/endpoints/i/notifications.ts
src/api/stream/home.ts
+31
-2
31 additions, 2 deletions
src/api/stream/home.ts
with
49 additions
and
7 deletions
src/api/endpoints/i/notifications.ts
+
18
−
5
View file @
6575a6de
...
...
@@ -3,6 +3,7 @@
*/
import
$
from
'
cafy
'
;
import
Notification
from
'
../../models/notification
'
;
import
Mute
from
'
../../models/mute
'
;
import
serialize
from
'
../../serializers/notification
'
;
import
getFriends
from
'
../../common/get-friends
'
;
import
read
from
'
../../common/read-notification
'
;
...
...
@@ -45,8 +46,18 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return
rej
(
'
cannot set since_id and until_id
'
);
}
const
mute
=
await
Mute
.
find
({
muter_id
:
user
.
_id
,
deleted_at
:
{
$exists
:
false
}
});
const
query
=
{
notifiee_id
:
user
.
_id
notifiee_id
:
user
.
_id
,
$and
:
[{
notifier_id
:
{
$nin
:
mute
.
map
(
m
=>
m
.
mutee_id
)
}
}]
}
as
any
;
const
sort
=
{
...
...
@@ -54,12 +65,14 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
};
if
(
following
)
{
// ID list of the user
$
self and other users who the user follows
// ID list of the user
it
self and other users who the user follows
const
followingIds
=
await
getFriends
(
user
.
_id
);
query
.
notifier_id
=
{
$in
:
followingIds
};
query
.
$and
.
push
({
notifier_id
:
{
$in
:
followingIds
}
});
}
if
(
type
)
{
...
...
This diff is collapsed.
Click to expand it.
src/api/stream/home.ts
+
31
−
2
View file @
6575a6de
...
...
@@ -3,19 +3,48 @@ import * as redis from 'redis';
import
*
as
debug
from
'
debug
'
;
import
User
from
'
../models/user
'
;
import
Mute
from
'
../models/mute
'
;
import
serializePost
from
'
../serializers/post
'
;
import
readNotification
from
'
../common/read-notification
'
;
const
log
=
debug
(
'
misskey
'
);
export
default
function
homeStream
(
request
:
websocket
.
request
,
connection
:
websocket
.
connection
,
subscriber
:
redis
.
RedisClient
,
user
:
any
)
:
void
{
export
default
async
function
(
request
:
websocket
.
request
,
connection
:
websocket
.
connection
,
subscriber
:
redis
.
RedisClient
,
user
:
any
)
{
// Subscribe Home stream channel
subscriber
.
subscribe
(
`misskey:user-stream:
${
user
.
_id
}
`
);
const
mute
=
await
Mute
.
find
({
muter_id
:
user
.
_id
,
deleted_at
:
{
$exists
:
false
}
});
const
mutedUserIds
=
mute
.
map
(
m
=>
m
.
mutee_id
.
toString
());
subscriber
.
on
(
'
message
'
,
async
(
channel
,
data
)
=>
{
switch
(
channel
.
split
(
'
:
'
)[
1
])
{
case
'
user-stream
'
:
connection
.
send
(
data
);
try
{
const
x
=
JSON
.
parse
(
data
);
if
(
x
.
type
==
'
post
'
)
{
if
(
mutedUserIds
.
indexOf
(
x
.
body
.
user_id
)
!=
-
1
)
{
return
;
}
if
(
x
.
body
.
reply
!=
null
&&
mutedUserIds
.
indexOf
(
x
.
body
.
reply
.
user_id
)
!=
-
1
)
{
return
;
}
if
(
x
.
body
.
repost
!=
null
&&
mutedUserIds
.
indexOf
(
x
.
body
.
repost
.
user_id
)
!=
-
1
)
{
return
;
}
}
else
if
(
x
.
type
==
'
notification
'
)
{
if
(
mutedUserIds
.
indexOf
(
x
.
body
.
user_id
)
!=
-
1
)
{
return
;
}
}
connection
.
send
(
data
);
}
catch
(
e
)
{
connection
.
send
(
data
);
}
break
;
case
'
post-stream
'
:
const
postId
=
channel
.
split
(
'
:
'
)[
2
];
...
...
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