Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
retribute.me
webclient
Commits
60ffdb3e
Verified
Commit
60ffdb3e
authored
Jun 11, 2019
by
Eliot Berriot
Browse files
Fixed support for Pleroma
parent
ab8f00e1
Pipeline
#4291
passed with stages
in 1 minute and 33 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/components/MastodonForm.vue
View file @
60ffdb3e
...
...
@@ -36,11 +36,23 @@ export default {
baseURL
:
instanceUrl
,
timeout
:
3000
,
})
let
response
=
await
createApp
(
ax
,
{
baseUrl
})
// we check wether the server is running pleroma or not, because
// pleroma support lets scopes than Mastodon
let
scopes
let
instanceResponse
=
await
ax
.
get
(
'
/api/v1/instance
'
)
let
version
=
instanceResponse
.
data
.
version
||
''
if
(
version
.
toLowerCase
().
indexOf
(
'
(compatible; pleroma
'
))
{
console
.
log
(
'
Pleroma detected, asking for "read" scope only!
'
)
scopes
=
'
read
'
}
else
{
console
.
log
(
'
Mastodon detected, using standard scopes
'
)
scopes
=
SCOPES
}
let
response
=
await
createApp
(
ax
,
{
baseUrl
,
scopes
})
const
appData
=
response
.
data
const
redirectUri
=
encodeURIComponent
(
`
${
baseUrl
}
/connect/mastodon/callback`
)
this
.
$store
.
commit
(
'
setRecursiveState
'
,
{
key
:
"
sources.mastodon.appCredentials
"
,
suffix
:
this
.
domain
,
value
:
appData
})
let
params
=
`response_type=code&scope=
${
encodeURIComponent
(
SCOPES
)}
&redirect_uri=
${
redirectUri
}
&state=
${
this
.
domain
}
&client_id=
${
appData
.
client_id
}
`
let
params
=
`response_type=code&scope=
${
encodeURIComponent
(
scopes
)}
&redirect_uri=
${
redirectUri
}
&state=
${
this
.
domain
}
&client_id=
${
appData
.
client_id
}
`
const
authorizeUrl
=
`
${
instanceUrl
}
oauth/authorize?
${
params
}
`
console
.
log
(
'
Redirecting user...
'
,
authorizeUrl
)
window
.
location
=
authorizeUrl
...
...
src/sources/mastodon.js
View file @
60ffdb3e
...
...
@@ -26,11 +26,11 @@ export function getAxios(url) {
}
export
async
function
createApp
(
ax
,
{
baseUrl
})
{
export
async
function
createApp
(
ax
,
{
baseUrl
,
scopes
})
{
const
payload
=
{
client_name
:
`Retribute
${
window
.
location
.
hostname
}
`
,
website
:
baseUrl
,
scopes
:
SCOPES
,
scopes
,
redirect_uris
:
`
${
baseUrl
}
/connect/mastodon/callback`
}
const
response
=
await
ax
.
post
(
'
/api/v1/apps
'
,
payload
)
...
...
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