Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
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
Container Registry
Model registry
Operate
Environments
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
kaniini
pleroma
Commits
34a1ce00
Commit
34a1ce00
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Set valid_until date.
parent
a2ca3b86
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/websub/websub_controller.ex
+4
-2
4 additions, 2 deletions
lib/pleroma/web/websub/websub_controller.ex
test/web/websub/websub_controller_test.exs
+2
-3
2 additions, 3 deletions
test/web/websub/websub_controller_test.exs
with
6 additions
and
5 deletions
lib/pleroma/web/websub/websub_controller.ex
+
4
−
2
View file @
34a1ce00
...
...
@@ -18,9 +18,11 @@ defmodule Pleroma.Web.Websub.WebsubController do
end
end
def
websub_subscription_confirmation
(
conn
,
%{
"id"
=>
id
,
"hub.mode"
=>
"subscribe"
,
"hub.challenge"
=>
challenge
,
"hub.topic"
=>
topic
})
do
# TODO: Extract this into the Websub module
def
websub_subscription_confirmation
(
conn
,
%{
"id"
=>
id
,
"hub.mode"
=>
"subscribe"
,
"hub.challenge"
=>
challenge
,
"hub.topic"
=>
topic
,
"hub.lease_seconds"
=>
lease_seconds
})
do
with
%
WebsubClientSubscription
{}
=
websub
<-
Repo
.
get_by
(
WebsubClientSubscription
,
id:
id
,
topic:
topic
)
do
change
=
Ecto
.
Changeset
.
change
(
websub
,
%{
state:
"accepted"
})
valid_until
=
NaiveDateTime
.
add
(
NaiveDateTime
.
utc_now
,
String
.
to_integer
(
lease_seconds
))
change
=
Ecto
.
Changeset
.
change
(
websub
,
%{
state:
"accepted"
,
valid_until:
valid_until
})
{
:ok
,
_websub
}
=
Repo
.
update
(
change
)
conn
|>
send_resp
(
200
,
challenge
)
...
...
This diff is collapsed.
Click to expand it.
test/web/websub/websub_controller_test.exs
+
2
−
3
View file @
34a1ce00
...
...
@@ -31,7 +31,7 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do
"hub.mode"
=>
"subscribe"
,
"hub.topic"
=>
websub
.
topic
,
"hub.challenge"
=>
"some challenge"
,
"hub.lease_seconds"
=>
100
"hub.lease_seconds"
=>
"
100
"
}
conn
=
conn
...
...
@@ -41,8 +41,7 @@ defmodule Pleroma.Web.Websub.WebsubControllerTest do
assert
response
(
conn
,
200
)
==
"some challenge"
assert
websub
.
state
==
"accepted"
# TODO valid_until
assert_in_delta
NaiveDateTime
.
diff
(
websub
.
valid_until
,
NaiveDateTime
.
utc_now
),
100
,
5
end
test
"handles incoming feed updates"
,
%{
conn:
conn
}
do
...
...
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