Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
848d7b4d
Commit
848d7b4d
authored
Sep 26, 2019
by
les
Browse files
[fedi] toot as admin only
parent
a4837daa
Changes
6
Hide whitespace changes
Inline
Side-by-side
config/default.json
View file @
848d7b4d
...
...
@@ -20,6 +20,6 @@
"secure"
:
true
,
"host"
:
""
},
"admin
"
:
"info@gancio.org
"
,
"admin
_email"
:
"admin
"
,
"secret"
:
"notsosecret"
}
pages/event/_id.vue
View file @
848d7b4d
...
...
@@ -44,7 +44,7 @@
small.float-right 🔖
{{
event
.
likes
.
length
}}
small.float-right.mr-3 ✊
{{
event
.
boost
.
length
}}
<br/>
strong
{{
$tc
(
'
common.comments
'
,
event
.
comments
.
length
)
}}
-
<small>
{{
$t
(
'
event.interact_with_me_at
'
)
}}
<u>
{{
event
.
user
&&
event
.
user
.
username
}}
@
{{
settings
.
baseurl
|
url2host
}}
</u></small>
<small>
{{
$t
(
'
event.interact_with_me_at
'
)
}}
<u>
{{
fedi_user
}}
@
{{
settings
.
baseurl
|
url2host
}}
</u></small>
.card-header(v-for='comment in event.comments' :key='comment.id')
a.float-right(:href='comment.data.url')
...
...
@@ -133,6 +133,10 @@ export default {
computed
:
{
...
mapGetters
([
'
filteredEvents
'
]),
...
mapState
([
'
settings
'
]),
fedi_user
()
{
// TODO:
return
this
.
settings
.
fedi_admin
},
next
()
{
let
found
=
false
const
event
=
this
.
filteredEvents
.
find
(
e
=>
{
...
...
server/api/controller/settings.js
View file @
848d7b4d
const
{
setting
:
Setting
}
=
require
(
'
../models
'
)
const
{
setting
:
Setting
,
user
:
User
}
=
require
(
'
../models
'
)
const
config
=
require
(
'
config
'
)
const
consola
=
require
(
'
consola
'
)
const
path
=
require
(
'
path
'
)
...
...
@@ -26,6 +26,12 @@ const settingsController = {
}
})
// set fediverse admin actor
const
fedi_admin
=
await
User
.
findOne
({
where
:
{
email
:
config
.
admin_email
}})
if
(
fedi_admin
)
{
settingsController
.
settings
[
'
fedi_admin
'
]
=
fedi_admin
.
username
}
// // initialize user_locale
if
(
config
.
user_locale
&&
fs
.
existsSync
(
path
.
resolve
(
config
.
user_locale
)))
{
const
user_locale
=
fs
.
readdirSync
(
path
.
resolve
(
config
.
user_locale
))
...
...
server/api/models/event.js
View file @
848d7b4d
...
...
@@ -38,7 +38,8 @@ module.exports = (sequelize, DataTypes) => {
//
event
.
prototype
.
toAP
=
function
(
username
,
follower
=
[])
{
const
tags
=
this
.
tags
&&
this
.
tags
.
map
(
t
=>
'
#
'
+
t
.
tag
).
join
(
'
'
)
const
tags
=
this
.
tags
&&
this
.
tags
.
map
(
t
=>
`<a href='/tags/
${
t
.
tag
}
' class='mention hashtag' rel='tag'>#
${
t
.
tag
}
</a>`
).
join
(
'
'
)
const
content
=
`<a href='
${
config
.
baseurl
}
/event/
${
this
.
id
}
'>
${
this
.
title
}
</a><br/>
📍
${
this
.
place
.
name
}
<br/>
⏰
${
moment
.
unix
(
this
.
start_datetime
).
format
(
'
dddd, D MMMM (HH:mm)
'
)}
<br/><br/>
...
...
@@ -57,13 +58,14 @@ module.exports = (sequelize, DataTypes) => {
}
return
{
type
:
'
Note
'
,
id
:
`
${
config
.
baseurl
}
/federation/m/
${
this
.
id
}
`
,
url
:
`
${
config
.
baseurl
}
/federation/m/
${
this
.
id
}
`
,
attachment
,
type
:
'
Note
'
,
// attachment,
tag
:
this
.
tags
.
map
(
tag
=>
({
type
:
'
Hashtag
'
,
name
:
'
#
'
+
tag
.
tag
name
:
'
#
'
+
tag
.
tag
,
href
:
'
/tags/
'
+
tag
.
tag
})),
published
:
this
.
createdAt
,
attributedTo
:
`
${
config
.
baseurl
}
/federation/u/
${
username
}
`
,
...
...
@@ -72,7 +74,12 @@ module.exports = (sequelize, DataTypes) => {
content
,
summary
:
null
,
sensitive
:
false
,
// }
startTime
:
moment
.
unix
(
this
.
start_datetime
),
location
:
{
type
:
'
Place
'
,
name
:
this
.
place
.
name
,
address
:
this
.
place
.
address
}
}
}
...
...
server/federation/helpers.js
View file @
848d7b4d
...
...
@@ -85,10 +85,15 @@ const Helpers = {
// object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]])
object
:
event
.
toAP
(
instanceAdmin
.
username
,
recipients
[
sharedInbox
])
}
body
[
'
@context
'
]
=
'
https://www.w3.org/ns/activitystreams
'
body
[
'
@context
'
]
=
[
'
https://www.w3.org/ns/activitystreams
'
,
'
https://w3id.org/security/v1
'
,
{
Hashtag
:
'
as:Hashtag
'
}
]
Helpers
.
signAndSend
(
body
,
instanceAdmin
,
sharedInbox
)
}
return
// TODO
// in case the event is published by the Admin itself do not add user
if
(
instanceAdmin
.
id
===
user
.
id
)
{
debug
(
'
Event published by instance Admin
'
)
...
...
server/firstrun.js
View file @
848d7b4d
...
...
@@ -45,7 +45,7 @@ module.exports = {
await
db
.
user
.
create
({
email
:
admin
.
email
,
password
:
admin
.
password
,
username
:
admin
.
email
,
username
:
config
.
title
.
toLowerCase
().
replace
(
/ /g
,
''
)
,
display_name
:
config
.
title
,
is_admin
:
true
,
is_active
:
true
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment