mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
[fedi] toot as admin only
This commit is contained in:
parent
a4837daa18
commit
848d7b4da4
6 changed files with 32 additions and 10 deletions
|
@ -20,6 +20,6 @@
|
|||
"secure": true,
|
||||
"host": ""
|
||||
},
|
||||
"admin": "info@gancio.org",
|
||||
"admin_email": "admin",
|
||||
"secret": "notsosecret"
|
||||
}
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
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))
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue