Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gab-social
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
gab
social
gab-social
Commits
cca45c54
Commit
cca45c54
authored
Aug 12, 2019
by
2458773093
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'quote-notifs' into feature/groups-improvements
* quote-notifs: quote notifs migration
parents
a12fa057
623fa7da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
0 deletions
+52
-0
app/models/notification.rb
app/models/notification.rb
+1
-0
app/models/status.rb
app/models/status.rb
+4
-0
app/services/post_status_service.rb
app/services/post_status_service.rb
+5
-0
app/services/process_quote_service.rb
app/services/process_quote_service.rb
+42
-0
No files found.
app/models/notification.rb
View file @
cca45c54
...
...
@@ -59,6 +59,7 @@ class Notification < ApplicationRecord
def
target_status
case
type
when
:reblog
return
status
if
status
&
.
quote?
status
&
.
reblog
when
:favourite
favourite
&
.
status
...
...
app/models/status.rb
View file @
cca45c54
...
...
@@ -162,6 +162,10 @@ class Status < ApplicationRecord
!
reblog_of_id
.
nil?
end
def
quote?
!
quote_of_id
.
nil?
end
def
within_realtime_window?
created_at
>=
REAL_TIME_WINDOW
.
ago
end
...
...
app/services/post_status_service.rb
View file @
cca45c54
...
...
@@ -68,6 +68,7 @@ class PostStatusService < BaseService
process_hashtags_service
.
call
(
@status
)
process_mentions_service
.
call
(
@status
)
process_quote_service
.
call
(
@status
)
end
def
schedule_status!
...
...
@@ -117,6 +118,10 @@ class PostStatusService < BaseService
ISO_639
.
find
(
str
)
&
.
alpha2
end
def
process_quote_service
ProcessQuoteService
.
new
end
def
process_mentions_service
ProcessMentionsService
.
new
end
...
...
app/services/process_quote_service.rb
0 → 100644
View file @
cca45c54
# frozen_string_literal: true
class
ProcessQuoteService
<
BaseService
include
StreamEntryRenderer
# Create notification for a quote
# @param [Status] status Quoting status
# @return [Status]
def
call
(
status
)
create_notification
(
status
)
bump_potential_friendship
(
status
)
end
private
def
create_notification
(
status
)
quoted_status
=
status
.
quote
if
quoted_status
.
account
.
local?
LocalNotificationWorker
.
perform_async
(
quoted_status
.
account_id
,
status
.
id
,
status
.
class
.
name
)
elsif
quoted_status
.
account
.
ostatus?
NotificationWorker
.
perform_async
(
stream_entry_to_xml
(
status
.
stream_entry
),
status
.
account_id
,
quoted_status
.
account_id
)
elsif
quoted_status
.
account
.
activitypub?
&&
!
quoted_status
.
account
.
following?
(
status
.
account
)
ActivityPub
::
DeliveryWorker
.
perform_async
(
build_json
(
status
),
status
.
account_id
,
quoted_status
.
account
.
inbox_url
)
end
end
def
bump_potential_friendship
(
status
)
ActivityTracker
.
increment
(
'activity:interactions'
)
return
if
status
.
account
.
following?
(
status
.
quote
.
account_id
)
PotentialFriendshipTracker
.
record
(
status
.
account_id
,
status
.
quote
.
account_id
,
:reblog
)
end
def
build_json
(
status
)
Oj
.
dump
(
ActivityPub
::
LinkedDataSignature
.
new
(
ActiveModelSerializers
::
SerializableResource
.
new
(
status
,
serializer:
ActivityPub
::
ActivitySerializer
,
adapter:
ActivityPub
::
Adapter
).
as_json
).
sign!
(
status
.
account
))
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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