Allow to join an open group

Also:

* Refactor interacting with a remote event so that you can interact with
  a remote group as well
* Add a setting for group admins to pick between an open and invite-only
  group
* Fix new groups without posts/todos/resources/events/conversations URL
  set
* Repair local groups that haven't got their
  posts/todos/resources/events/conversations URL set
* Add a scheduled job to refresh remote groups every hour
* Add a user setting to pick when to receive notifications when there's
  new members to approve (will be used when this feature is available)
* Fix pagination for members

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-11-06 11:34:32 +01:00
parent 7baad7cafc
commit 7c11807c14
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
74 changed files with 1174 additions and 626 deletions

View File

@ -263,7 +263,8 @@ config :mobilizon, Oban,
log: false,
queues: [default: 10, search: 5, mailers: 10, background: 5],
crontab: [
{"@hourly", Mobilizon.Service.Workers.BuildSiteMap, queue: :background}
{"@hourly", Mobilizon.Service.Workers.BuildSiteMap, queue: :background},
{"17 * * * *", Mobilizon.Service.Workers.RefreshGroups, queue: :background}
]
config :mobilizon, :rich_media,

View File

@ -65,8 +65,8 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { Person } from "../../types/actor";
import { IParticipant, ParticipantRole } from "../../types/event.model";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
import { IPerson, Person } from "../../types/actor";
@Component
export default class ParticipantCard extends Vue {
@ -81,7 +81,7 @@ export default class ParticipantCard extends Vue {
ParticipantRole = ParticipantRole;
get actorDisplayName(): string {
const actor = new Person(this.participant.actor);
const actor = new Person(this.participant.actor as IPerson);
return actor.displayName();
}
}

View File

@ -137,11 +137,12 @@ import { Component, Prop, Vue, Ref } from "vue-property-decorator";
import EditorComponent from "@/components/Editor.vue";
import { SnackbarProgrammatic as Snackbar } from "buefy";
import { formatDistanceToNow } from "date-fns";
import { CommentModeration } from "../../types/event-options.model";
import { CommentModel, IComment } from "../../types/comment.model";
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
import { IPerson, usernameWithDomain } from "../../types/actor";
import { COMMENTS_THREADS, FETCH_THREAD_REPLIES } from "../../graphql/comment";
import { IEvent, CommentModeration } from "../../types/event.model";
import { IEvent } from "../../types/event.model";
import ReportModal from "../Report/ReportModal.vue";
import { IReport } from "../../types/report.model";
import { CREATE_REPORT } from "../../graphql/report";

View File

@ -51,6 +51,7 @@
import { Prop, Vue, Component, Watch } from "vue-property-decorator";
import Comment from "@/components/Comment/Comment.vue";
import IdentityPickerWrapper from "@/views/Account/IdentityPickerWrapper.vue";
import { CommentModeration } from "../../types/event-options.model";
import { CommentModel, IComment } from "../../types/comment.model";
import {
CREATE_COMMENT_FROM_EVENT,
@ -60,7 +61,7 @@ import {
} from "../../graphql/comment";
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
import { IPerson } from "../../types/actor";
import { IEvent, CommentModeration } from "../../types/event.model";
import { IEvent } from "../../types/event.model";
@Component({
apollo: {

View File

@ -73,10 +73,11 @@
</template>
<script lang="ts">
import { IEvent, IEventCardOptions, ParticipantRole } from "@/types/event.model";
import { IEvent, IEventCardOptions } from "@/types/event.model";
import { Component, Prop, Vue } from "vue-property-decorator";
import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue";
import { Actor, Person } from "@/types/actor";
import { ParticipantRole } from "../../types/participant.model";
import RouteName from "../../router/name";
@Component({

View File

@ -187,12 +187,8 @@ import { Component, Prop } from "vue-property-decorator";
import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue";
import { mixins } from "vue-class-component";
import { RawLocation, Route } from "vue-router";
import {
IParticipant,
ParticipantRole,
EventVisibility,
IEventCardOptions,
} from "../../types/event.model";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
import { EventVisibility, IEventCardOptions } from "../../types/event.model";
import { IPerson } from "../../types/actor";
import ActorMixin from "../../mixins/actor";
import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";

View File

@ -51,7 +51,7 @@
</template>
<script lang="ts">
import { ParticipantRole, EventVisibility, IEventCardOptions, IEvent } from "@/types/event.model";
import { EventVisibility, IEventCardOptions, IEvent } from "@/types/event.model";
import { Component, Prop } from "vue-property-decorator";
import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue";
import { IPerson, usernameWithDomain } from "@/types/actor";
@ -59,6 +59,7 @@ import { mixins } from "vue-class-component";
import ActorMixin from "@/mixins/actor";
import { CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import EventMixin from "@/mixins/event";
import { ParticipantRole } from "../../types/participant.model";
import RouteName from "../../router/name";
const defaultOptions: IEventCardOptions = {

View File

@ -56,6 +56,7 @@
import { Component, Prop, Vue } from "vue-property-decorator";
import { IEvent } from "@/types/event.model";
import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue";
import { ParticipantRole } from "../../types/participant.model";
import RouteName from "../../router/name";
@Component({
@ -67,6 +68,8 @@ export default class EventMinimalistCard extends Vue {
@Prop({ required: true, type: Object }) event!: IEvent;
RouteName = RouteName;
ParticipantRole = ParticipantRole;
}
</script>
<style lang="scss" scoped>

View File

@ -142,7 +142,8 @@ A button to set your participation
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { EventJoinOptions, IEvent, IParticipant, ParticipantRole } from "../../types/event.model";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
import { EventJoinOptions, IEvent } from "../../types/event.model";
import { IPerson, Person } from "../../types/actor";
import { CURRENT_ACTOR_CLIENT, IDENTITIES } from "../../graphql/actor";
import { CURRENT_USER_CLIENT } from "../../graphql/user";
@ -182,20 +183,20 @@ export default class ParticipationButton extends Vue {
RouteName = RouteName;
joinEvent(actor: IPerson) {
joinEvent(actor: IPerson): void {
if (this.event.joinOptions === EventJoinOptions.RESTRICTED) {
this.$emit("joinEventWithConfirmation", actor);
this.$emit("join-event-with-confirmation", actor);
} else {
this.$emit("joinEvent", actor);
this.$emit("join-event", actor);
}
}
joinModal() {
this.$emit("joinModal");
joinModal(): void {
this.$emit("join-modal");
}
confirmLeave() {
this.$emit("confirmLeave");
confirmLeave(): void {
this.$emit("confirm-leave");
}
get hasAnonymousParticipationMethods(): boolean {

View File

@ -41,7 +41,7 @@ section {
.create-slot {
display: flex;
justify-content: end;
justify-content: flex-end;
padding-bottom: 0.5rem;
padding-right: 0.5rem;
}

View File

@ -0,0 +1,30 @@
<template>
<redirect-with-account
:uri="uri"
:pathAfterLogin="`/@${preferredUsername}`"
:sentence="sentence"
/>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import RedirectWithAccount from "@/components/Utils/RedirectWithAccount.vue";
import RouteName from "../../router/name";
@Component({
components: { RedirectWithAccount },
})
export default class JoinGroupWithAccount extends Vue {
@Prop({ type: String, required: true }) preferredUsername!: string;
get uri(): string {
return `${window.location.origin}${
this.$router.resolve({
name: RouteName.GROUP,
params: { preferredUsername: this.preferredUsername },
}).href
}`;
}
sentence = this.$t("We will redirect you to your instance in order to interact with this group");
}
</script>

View File

@ -38,8 +38,9 @@
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { confirmLocalAnonymousParticipation } from "@/services/AnonymousParticipationStorage";
import { IParticipant } from "../../types/participant.model";
import RouteName from "../../router/name";
import { EventJoinOptions, IParticipant } from "../../types/event.model";
import { EventJoinOptions } from "../../types/event.model";
import { CONFIRM_PARTICIPATION } from "../../graphql/event";
@Component

View File

@ -1,71 +1,17 @@
<template>
<section class="section container hero is-fullheight">
<div class="hero-body">
<div class="container">
<div class="columns is-vcentered">
<div class="column has-text-centered">
<b-button
type="is-primary"
size="is-medium"
tag="router-link"
:to="{ name: RouteName.LOGIN }"
>{{ $t("Login on {instance}", { instance: host }) }}</b-button
>
</div>
<vertical-divider :content="$t('Or')" />
<div class="column">
<subtitle>{{ $t("I have an account on another Mobilizon instance.") }}</subtitle>
<p>{{ $t("Other software may also support this.") }}</p>
<p>
{{ $t("We will redirect you to your instance in order to interact with this event") }}
</p>
<form @submit.prevent="redirectToInstance">
<b-field :label="$t('Your federated identity')">
<b-field>
<b-input
expanded
autocapitalize="none"
autocorrect="off"
v-model="remoteActorAddress"
:placeholder="$t('profile@instance')"
></b-input>
<p class="control">
<button class="button is-primary" type="submit">{{ $t("Go") }}</button>
</p>
</b-field>
</b-field>
</form>
</div>
</div>
<div class="has-text-centered">
<b-button tag="a" type="is-text" @click="$router.go(-1)">{{
$t("Back to previous page")
}}</b-button>
</div>
</div>
</div>
</section>
<redirect-with-account :uri="uri" :pathAfterLogin="`/events/${uuid}`" :sentence="sentence" />
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import VerticalDivider from "@/components/Utils/VerticalDivider.vue";
import Subtitle from "@/components/Utils/Subtitle.vue";
import RedirectWithAccount from "@/components/Utils/RedirectWithAccount.vue";
import RouteName from "../../router/name";
@Component({
components: { Subtitle, VerticalDivider },
components: { RedirectWithAccount },
})
export default class ParticipationWithAccount extends Vue {
@Prop({ type: String, required: true }) uuid!: string;
remoteActorAddress = "";
RouteName = RouteName;
get host() {
return window.location.hostname;
}
get uri(): string {
return `${window.location.origin}${
this.$router.resolve({
@ -75,31 +21,6 @@ export default class ParticipationWithAccount extends Vue {
}`;
}
async redirectToInstance() {
let res;
const [_, host] = (res = this.remoteActorAddress.split("@", 2));
const remoteInteractionURI = await this.webFingerFetch(host, this.remoteActorAddress);
window.open(remoteInteractionURI);
}
private async webFingerFetch(hostname: string, identity: string): Promise<string> {
const scheme = process.env.NODE_ENV === "production" ? "https" : "http";
const data = await (
await fetch(`${scheme}://${hostname}/.well-known/webfinger?resource=acct:${identity}`)
).json();
if (data && Array.isArray(data.links)) {
const link: { template: string } = data.links.find(
(link: any) =>
link &&
typeof link.template === "string" &&
link.rel === "http://ostatus.org/schema/1.0/subscribe"
);
if (link && link.template.includes("{uri}")) {
return link.template.replace("{uri}", encodeURIComponent(this.uri));
}
}
throw new Error("No interaction path found in webfinger data");
}
sentence = this.$t("We will redirect you to your instance in order to interact with this event");
}
</script>

View File

@ -74,19 +74,12 @@
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import {
EventModel,
IEvent,
IParticipant,
ParticipantRole,
EventJoinOptions,
} from "@/types/event.model";
import { EventModel, IEvent, EventJoinOptions } from "@/types/event.model";
import { FETCH_EVENT, JOIN_EVENT } from "@/graphql/event";
import { IConfig } from "@/types/config.model";
import { CONFIG } from "@/graphql/config";
import { addLocalUnconfirmedAnonymousParticipation } from "@/services/AnonymousParticipationStorage";
import { Route } from "vue-router";
import RouteName from "../../router/name";
import { IParticipant, ParticipantRole } from "../../types/participant.model";
@Component({
apollo: {
@ -139,8 +132,8 @@ export default class ParticipationWithoutAccount extends Vue {
message: this.anonymousParticipation.message,
locale: this.$i18n.locale,
},
update: (store, { data }) => {
if (data == null) {
update: (store, { data: updateData }) => {
if (updateData == null) {
console.error("Cannot update event participant cache, because of data null value.");
return;
}
@ -159,7 +152,7 @@ export default class ParticipationWithoutAccount extends Vue {
return;
}
if (data.joinEvent.role === ParticipantRole.NOT_CONFIRMED) {
if (updateData.joinEvent.role === ParticipantRole.NOT_CONFIRMED) {
event.participantStats.notConfirmed += 1;
} else {
event.participantStats.going += 1;

View File

@ -26,12 +26,9 @@
</div>
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import { Component, Vue } from "vue-property-decorator";
import { USER_SETTINGS, SET_USER_SETTINGS } from "../../graphql/user";
import {
ICurrentUser,
INotificationPendingParticipationEnum,
} from "../../types/current-user.model";
import { ICurrentUser } from "../../types/current-user.model";
import RouteName from "../../router/name";
@Component({
@ -46,7 +43,7 @@ export default class SettingsOnboarding extends Vue {
RouteName = RouteName;
async updateSetting(variables: object) {
async updateSetting(variables: Record<string, unknown>): Promise<void> {
await this.$apollo.mutate<{ setUserSettings: string }>({
mutation: SET_USER_SETTINGS,
variables,

View File

@ -0,0 +1,107 @@
<template>
<section class="section container hero is-fullheight">
<div class="hero-body">
<div class="container">
<div class="columns is-vcentered">
<div class="column has-text-centered">
<b-button
type="is-primary"
size="is-medium"
tag="router-link"
:to="{
name: RouteName.LOGIN,
query: {
code: LoginErrorCode.NEED_TO_LOGIN,
redirect: pathAfterLogin,
},
}"
>{{ $t("Login on {instance}", { instance: host }) }}</b-button
>
</div>
<vertical-divider :content="$t('Or')" />
<div class="column">
<subtitle>{{ $t("I have an account on another Mobilizon instance.") }}</subtitle>
<p>{{ $t("Other software may also support this.") }}</p>
<p>{{ sentence }}</p>
<form @submit.prevent="redirectToInstance">
<b-field :label="$t('Your federated identity')">
<b-field>
<b-input
expanded
autocapitalize="none"
autocorrect="off"
v-model="remoteActorAddress"
:placeholder="$t('profile@instance')"
></b-input>
<p class="control">
<button class="button is-primary" type="submit">{{ $t("Go") }}</button>
</p>
</b-field>
</b-field>
</form>
</div>
</div>
<div class="has-text-centered">
<b-button tag="a" type="is-text" @click="$router.go(-1)">{{
$t("Back to previous page")
}}</b-button>
</div>
</div>
</div>
</section>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import VerticalDivider from "@/components/Utils/VerticalDivider.vue";
import Subtitle from "@/components/Utils/Subtitle.vue";
import { LoginErrorCode } from "@/types/login-error-code.model";
import RouteName from "../../router/name";
@Component({
components: { Subtitle, VerticalDivider },
})
export default class RedirectWithAccount extends Vue {
@Prop({ type: String, required: true }) uri!: string;
@Prop({ type: String, required: false }) pathAfterLogin!: string;
@Prop({ type: String, required: false }) sentence!: string;
remoteActorAddress = "";
RouteName = RouteName;
LoginErrorCode = LoginErrorCode;
// eslint-disable-next-line class-methods-use-this
get host(): string {
return window.location.hostname;
}
async redirectToInstance(): Promise<void> {
const [, host] = this.remoteActorAddress.split("@", 2);
const remoteInteractionURI = await this.webFingerFetch(host, this.remoteActorAddress);
window.open(remoteInteractionURI);
}
private async webFingerFetch(hostname: string, identity: string): Promise<string> {
const scheme = process.env.NODE_ENV === "production" ? "https" : "http";
const data = await (
await fetch(`${scheme}://${hostname}/.well-known/webfinger?resource=acct:${identity}`)
).json();
if (data && Array.isArray(data.links)) {
const link: { template: string } = data.links.find(
(someLink: any) =>
someLink &&
typeof someLink.template === "string" &&
someLink.rel === "http://ostatus.org/schema/1.0/subscribe"
);
if (link && link.template.includes("{uri}")) {
return link.template.replace("{uri}", encodeURIComponent(this.uri));
}
}
throw new Error("No interaction path found in webfinger data");
}
}
</script>

View File

@ -574,3 +574,35 @@ export const EVENT_PERSON_PARTICIPATION_SUBSCRIPTION_CHANGED = gql`
}
}
`;
export const GROUP_MEMBERSHIP_SUBSCRIPTION_CHANGED = gql`
subscription($actorId: ID!) {
groupMembershipChanged(personId: $actorId) {
id
memberships {
total
elements {
id
role
parent {
id
preferredUsername
name
domain
avatar {
id
url
}
}
invitedBy {
id
preferredUsername
name
}
insertedAt
updatedAt
}
}
}
}
`;

View File

@ -63,6 +63,7 @@ export const GROUP_FIELDS_FRAGMENTS = gql`
preferredUsername
suspended
visibility
openness
physicalAddress {
description
street
@ -262,6 +263,7 @@ export const UPDATE_GROUP = gql`
$avatar: PictureInput
$banner: PictureInput
$visibility: GroupVisibility
$openness: Openness
$physicalAddress: AddressInput
) {
updateGroup(
@ -271,12 +273,15 @@ export const UPDATE_GROUP = gql`
banner: $banner
avatar: $avatar
visibility: $visibility
openness: $openness
physicalAddress: $physicalAddress
) {
id
preferredUsername
name
summary
visibility
openness
avatar {
id
url

View File

@ -100,3 +100,12 @@ export const REMOVE_MEMBER = gql`
}
}
`;
export const JOIN_GROUP = gql`
mutation JoinGroup($groupId: ID!) {
joinGroup(groupId: $groupId) {
...MemberFragment
}
}
${MEMBER_FRAGMENT}
`;

View File

@ -78,3 +78,36 @@ export const SEARCH_PERSONS = gql`
}
}
`;
export const INTERACT = gql`
query Interact($uri: String!) {
interact(uri: $uri) {
... on Event {
id
title
uuid
beginsOn
picture {
id
url
}
tags {
slug
title
}
__typename
}
... on Group {
id
avatar {
id
url
}
domain
preferredUsername
name
__typename
}
}
}
`;

View File

@ -119,6 +119,7 @@ export const USER_SETTINGS_FRAGMENT = gql`
notificationEachWeek
notificationBeforeEvent
notificationPendingParticipation
notificationPendingMembership
}
`;
@ -141,7 +142,8 @@ export const SET_USER_SETTINGS = gql`
$notificationOnDay: Boolean
$notificationEachWeek: Boolean
$notificationBeforeEvent: Boolean
$notificationPendingParticipation: NotificationPendingParticipationEnum
$notificationPendingParticipation: NotificationPendingEnum
$notificationPendingMembership: NotificationPendingEnum
) {
setUserSettings(
timezone: $timezone
@ -149,6 +151,7 @@ export const SET_USER_SETTINGS = gql`
notificationEachWeek: $notificationEachWeek
notificationBeforeEvent: $notificationBeforeEvent
notificationPendingParticipation: $notificationPendingParticipation
notificationPendingMembership: $notificationPendingMembership
) {
...UserSettingFragment
}

View File

@ -277,7 +277,6 @@
"Publish": "Publish",
"Published events with <b>{comments}</b> comments and <b>{participations}</b> confirmed participations": "Published events with <b>{comments}</b> comments and <b>{participations}</b> confirmed participations",
"RSS/Atom Feed": "RSS/Atom Feed",
"Redirecting to event…": "Redirecting to event…",
"Region": "Region",
"Register an account on Mobilizon!": "Register an account on Mobilizon!",
"Registration is allowed, anyone can register.": "Registration is allowed, anyone can register.",
@ -733,7 +732,6 @@
"Group {groupTitle} reported": "Group {groupTitle} reported",
"Error while reporting group {groupTitle}": "Error while reporting group {groupTitle}",
"Reported group": "Reported group",
"You can only get invited to groups right now.": "You can only get invited to groups right now.",
"Join group": "Join group",
"Created by {username}": "Created by {username}",
"Accessible through link": "Accessible through link",
@ -790,5 +788,14 @@
"This group doesn't have a description yet.": "This group doesn't have a description yet.",
"Find another instance": "Find another instance",
"Pick an instance": "Pick an instance",
"This website isn't moderated and the data that you enter will be automatically destroyed every day at 00:01 (Paris timezone).": "This website isn't moderated and the data that you enter will be automatically destroyed every day at 00:01 (Paris timezone)."
"This website isn't moderated and the data that you enter will be automatically destroyed every day at 00:01 (Paris timezone).": "This website isn't moderated and the data that you enter will be automatically destroyed every day at 00:01 (Paris timezone).",
"We will redirect you to your instance in order to interact with this group": "",
"New members": "New members",
"Anyone can join freely": "Anyone can join freely",
"Anyone wanting to be a member from your group will be able to from your group page.": "Anyone wanting to be a member from your group will be able to from your group page.",
"Manually invite new members": "Manually invite new members",
"The only way for your group to get new members is if an admininistrator invites them.": "The only way for your group to get new members is if an admininistrator invites them.",
"Redirecting to content…": "Redirecting to content…",
"This URL is not supported": "This URL is not supported",
"This group is invite-only": "This group is invite-only"
}

View File

@ -870,5 +870,14 @@
"{profile} (by default)": "{profile} (par défault)",
"{title} ({count} todos)": "{title} ({count} todos)",
"{username} was invited to {group}": "{username} a été invité à {group}",
"© The OpenStreetMap Contributors": "© Les Contributeur⋅ices OpenStreetMap"
"© The OpenStreetMap Contributors": "© Les Contributeur⋅ices OpenStreetMap",
"We will redirect you to your instance in order to interact with this group": "",
"New members": "Nouveaux·elles membres",
"Anyone can join freely": "N'importe qui peut rejoindre",
"Anyone wanting to be a member from your group will be able to from your group page.": "N'importe qui voulant devenir membre pourra le faire depuis votre page de groupe.",
"Manually invite new members": "Inviter des nouveaux·elles membres manuellement",
"The only way for your group to get new members is if an admininistrator invites them.": "La seule manière pour votre groupe d'obtenir de nouveaux·elles membres sera si un·e administrateur·ice les invite.",
"Redirecting to content…": "Redirection vers le contenu…",
"This URL is not supported": "Cette URL n'est pas supportée",
"This group is invite-only": "Ce groupe est accessible uniquement sur invitation"
}

View File

@ -10,7 +10,7 @@
"fi": "suomi",
"fr": "Français",
"gl": "Galego",
"hu": "Magyar nyelv",
"hu": "Magyar",
"it": "Italiano",
"ja": "日本語",
"kn": "Kannada",

View File

@ -1,13 +1,14 @@
import { mixins } from "vue-class-component";
import { Component, Vue } from "vue-property-decorator";
import { IEvent, IParticipant, ParticipantRole } from "../types/event.model";
import { SnackbarProgrammatic as Snackbar } from "buefy";
import { IParticipant, ParticipantRole } from "../types/participant.model";
import { IEvent } from "../types/event.model";
import {
DELETE_EVENT,
EVENT_PERSON_PARTICIPATION,
FETCH_EVENT,
LEAVE_EVENT,
} from "../graphql/event";
import { SnackbarProgrammatic as Snackbar } from "buefy";
import { IPerson } from "../types/actor";
@Component
@ -17,7 +18,7 @@ export default class EventMixin extends mixins(Vue) {
actorId: string,
token: string | null = null,
anonymousParticipationConfirmed: boolean | null = null
) {
): Promise<void> {
try {
const { data: resultData } = await this.$apollo.mutate<{ leaveEvent: IParticipant }>({
mutation: LEAVE_EVENT,
@ -89,7 +90,7 @@ export default class EventMixin extends mixins(Vue) {
this.$notifier.success(this.$t("You have cancelled your participation") as string);
}
protected async openDeleteEventModal(event: IEvent, currentActor: IPerson) {
protected async openDeleteEventModal(event: IEvent, currentActor: IPerson): Promise<void> {
function escapeRegExp(string: string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
}
@ -135,7 +136,7 @@ export default class EventMixin extends mixins(Vue) {
*
* @type {string}
*/
this.$emit("eventDeleted", event.id);
this.$emit("event-deleted", event.id);
this.$buefy.notification.open({
message: this.$t("Event {eventTitle} deleted", { eventTitle }) as string,
@ -150,6 +151,7 @@ export default class EventMixin extends mixins(Vue) {
}
}
// eslint-disable-next-line class-methods-use-this
urlToHostname(url: string): string | null {
try {
return new URL(url).hostname;

View File

@ -1,4 +1,5 @@
import { PERSON_MEMBERSHIPS, CURRENT_ACTOR_CLIENT } from "@/graphql/actor";
import { GROUP_MEMBERSHIP_SUBSCRIPTION_CHANGED } from "@/graphql/event";
import { FETCH_GROUP } from "@/graphql/group";
import RouteName from "@/router/name";
import { Group, IActor, IGroup, IPerson, MemberRole } from "@/types/actor";
@ -29,6 +30,17 @@ import { Component, Vue } from "vue-property-decorator";
id: this.currentActor.id,
};
},
subscribeToMore: {
document: GROUP_MEMBERSHIP_SUBSCRIPTION_CHANGED,
variables() {
return {
actorId: this.currentActor.id,
};
},
skip() {
return !this.currentActor || !this.currentActor.id;
},
},
skip() {
return !this.currentActor || !this.currentActor.id;
},

View File

@ -15,6 +15,7 @@ export enum GroupsRouteName {
POST = "POST",
POSTS = "POSTS",
GROUP_EVENTS = "GROUP_EVENTS",
GROUP_JOIN = "GROUP_JOIN",
}
const resourceFolder = () => import("@/views/Resources/ResourceFolder.vue");
@ -97,17 +98,27 @@ export const groupsRoutes: RouteConfig[] = [
component: () => import("@/views/Posts/Post.vue"),
props: true,
name: GroupsRouteName.POST,
meta: { requiredAuth: false },
},
{
path: "/@:preferredUsername/p",
component: () => import("@/views/Posts/List.vue"),
props: true,
name: GroupsRouteName.POSTS,
meta: { requiredAuth: false },
},
{
path: "/@:preferredUsername/events",
component: groupEvents,
props: true,
name: GroupsRouteName.GROUP_EVENTS,
meta: { requiredAuth: false },
},
{
path: "/@:preferredUsername/join",
component: () => import("@/components/Group/JoinGroupWithAccount.vue"),
props: true,
name: GroupsRouteName.GROUP_JOIN,
meta: { requiredAuth: false },
},
];

View File

@ -42,7 +42,7 @@ export class Actor implements IActor {
type: ActorType = ActorType.PERSON;
constructor(hash: IActor | {} = {}) {
constructor(hash: IActor | Record<any, unknown> = {}) {
Object.assign(this, hash);
}

View File

@ -18,13 +18,10 @@ export enum MemberRole {
REJECTED = "REJECTED",
}
export interface IGroup extends IActor {
members: Paginate<IMember>;
resources: Paginate<IResource>;
todoLists: Paginate<ITodoList>;
discussions: Paginate<IDiscussion>;
organizedEvents: Paginate<IEvent>;
physicalAddress: IAddress;
export enum Openness {
INVITE_ONLY = "INVITE_ONLY",
MODERATED = "MODERATED",
OPEN = "OPEN",
}
export interface IMember {
@ -37,6 +34,16 @@ export interface IMember {
updatedAt: string;
}
export interface IGroup extends IActor {
members: Paginate<IMember>;
resources: Paginate<IResource>;
todoLists: Paginate<ITodoList>;
discussions: Paginate<IDiscussion>;
organizedEvents: Paginate<IEvent>;
physicalAddress: IAddress;
openness: Openness;
}
export class Group extends Actor implements IGroup {
members: Paginate<IMember> = { elements: [], total: 0 };
@ -50,16 +57,18 @@ export class Group extends Actor implements IGroup {
posts: Paginate<IPost> = { elements: [], total: 0 };
constructor(hash: IGroup | {} = {}) {
constructor(hash: IGroup | Record<string, unknown> = {}) {
super(hash);
this.type = ActorType.GROUP;
this.patch(hash);
}
openness: Openness = Openness.INVITE_ONLY;
physicalAddress: IAddress = new Address();
patch(hash: any) {
patch(hash: IGroup | Record<string, unknown>): void {
Object.assign(this, hash);
}
}

View File

@ -1,8 +1,9 @@
import { ICurrentUser } from "../current-user.model";
import { IEvent, IParticipant } from "../event.model";
import { IEvent } from "../event.model";
import { Actor, IActor } from "./actor.model";
import { Paginate } from "../paginate";
import { IMember } from "./group.model";
import { IParticipant } from "../participant.model";
export interface IFeedToken {
token: string;
@ -29,13 +30,13 @@ export class Person extends Actor implements IPerson {
user!: ICurrentUser;
constructor(hash: IPerson | {} = {}) {
constructor(hash: IPerson | Record<string, unknown> = {}) {
super(hash);
this.patch(hash);
}
patch(hash: any) {
patch(hash: IPerson | Record<string, unknown>): void {
Object.assign(this, hash);
}
}

View File

@ -1,6 +1,7 @@
import { IEvent, IParticipant } from "@/types/event.model";
import { IEvent } from "@/types/event.model";
import { IPerson } from "@/types/actor/person.model";
import { Paginate } from "./paginate";
import { IParticipant } from "./participant.model";
export enum ICurrentUserRole {
USER = "USER",
@ -16,7 +17,7 @@ export interface ICurrentUser {
defaultActor?: IPerson;
}
export enum INotificationPendingParticipationEnum {
export enum INotificationPendingEnum {
NONE = "NONE",
DIRECT = "DIRECT",
ONE_DAY = "ONE_DAY",
@ -28,7 +29,8 @@ export interface IUserSettings {
notificationOnDay: boolean;
notificationEachWeek: boolean;
notificationBeforeEvent: boolean;
notificationPendingParticipation: INotificationPendingParticipationEnum;
notificationPendingParticipation: INotificationPendingEnum;
notificationPendingMembership: INotificationPendingEnum;
}
export interface IUser extends ICurrentUser {

View File

@ -0,0 +1,61 @@
export interface IParticipationCondition {
title: string;
content: string;
url: string;
}
export interface IOffer {
price: number;
priceCurrency: string;
url: string;
}
export enum CommentModeration {
ALLOW_ALL = "ALLOW_ALL",
MODERATED = "MODERATED",
CLOSED = "CLOSED",
}
export interface IEventOptions {
maximumAttendeeCapacity: number;
remainingAttendeeCapacity: number;
showRemainingAttendeeCapacity: boolean;
anonymousParticipation: boolean;
hideOrganizerWhenGroupEvent: boolean;
offers: IOffer[];
participationConditions: IParticipationCondition[];
attendees: string[];
program: string;
commentModeration: CommentModeration;
showParticipationPrice: boolean;
showStartTime: boolean;
showEndTime: boolean;
}
export class EventOptions implements IEventOptions {
maximumAttendeeCapacity = 0;
remainingAttendeeCapacity = 0;
showRemainingAttendeeCapacity = false;
anonymousParticipation = false;
hideOrganizerWhenGroupEvent = false;
offers: IOffer[] = [];
participationConditions: IParticipationCondition[] = [];
attendees: string[] = [];
program = "";
commentModeration = CommentModeration.ALLOW_ALL;
showParticipationPrice = false;
showStartTime = true;
showEndTime = true;
}

View File

@ -3,7 +3,9 @@ import { ITag } from "@/types/tag.model";
import { IPicture } from "@/types/picture.model";
import { IComment } from "@/types/comment.model";
import { Paginate } from "@/types/paginate";
import { Actor, Group, IActor, IPerson } from "./actor";
import { Actor, Group, IActor, IGroup, IPerson } from "./actor";
import { IParticipant } from "./participant.model";
import { EventOptions, IEventOptions } from "./event-options.model";
export enum EventStatus {
TENTATIVE = "TENTATIVE",
@ -30,16 +32,6 @@ export enum EventVisibilityJoinOptions {
LIMITED = "LIMITED",
}
export enum ParticipantRole {
NOT_APPROVED = "NOT_APPROVED",
NOT_CONFIRMED = "NOT_CONFIRMED",
REJECTED = "REJECTED",
PARTICIPANT = "PARTICIPANT",
MODERATOR = "MODERATOR",
ADMINISTRATOR = "ADMINISTRATOR",
CREATOR = "CREATOR",
}
export enum Category {
BUSINESS = "business",
CONFERENCE = "conference",
@ -56,58 +48,6 @@ export interface IEventCardOptions {
memberofGroup: boolean;
}
export interface IParticipant {
id?: string;
role: ParticipantRole;
actor: IActor;
event: IEvent;
metadata: { cancellationToken?: string; message?: string };
insertedAt?: Date;
}
export class Participant implements IParticipant {
id?: string;
event!: IEvent;
actor!: IActor;
role: ParticipantRole = ParticipantRole.NOT_APPROVED;
metadata = {};
insertedAt?: Date;
constructor(hash?: IParticipant) {
if (!hash) return;
this.id = hash.id;
this.event = new EventModel(hash.event);
this.actor = new Actor(hash.actor);
this.role = hash.role;
this.metadata = hash.metadata;
this.insertedAt = hash.insertedAt;
}
}
export interface IOffer {
price: number;
priceCurrency: string;
url: string;
}
export interface IParticipationCondition {
title: string;
content: string;
url: string;
}
export enum CommentModeration {
ALLOW_ALL = "ALLOW_ALL",
MODERATED = "MODERATED",
CLOSED = "CLOSED",
}
export interface IEventParticipantStats {
notApproved: number;
notConfirmed: number;
@ -119,6 +59,26 @@ export interface IEventParticipantStats {
going: number;
}
interface IEventEditJSON {
id?: string;
title: string;
description: string;
beginsOn: string;
endsOn: string | null;
status: EventStatus;
visibility: EventVisibility;
joinOptions: EventJoinOptions;
draft: boolean;
picture: IPicture | { pictureId: string } | null;
attributedToId: string | null;
onlineAddress?: string;
phoneAddress?: string;
physicalAddress?: IAddress;
tags: string[];
options: IEventOptions;
contacts: { id?: string }[];
}
export interface IEvent {
id?: string;
uuid: string;
@ -139,7 +99,7 @@ export interface IEvent {
picture: IPicture | null;
organizerActor?: IActor;
attributedTo?: IActor;
attributedTo?: IGroup;
participantStats: IEventParticipantStats;
participants: Paginate<IParticipant>;
@ -157,50 +117,6 @@ export interface IEvent {
toEditJSON(): IEventEditJSON;
}
export interface IEventOptions {
maximumAttendeeCapacity: number;
remainingAttendeeCapacity: number;
showRemainingAttendeeCapacity: boolean;
anonymousParticipation: boolean;
hideOrganizerWhenGroupEvent: boolean;
offers: IOffer[];
participationConditions: IParticipationCondition[];
attendees: string[];
program: string;
commentModeration: CommentModeration;
showParticipationPrice: boolean;
showStartTime: boolean;
showEndTime: boolean;
}
export class EventOptions implements IEventOptions {
maximumAttendeeCapacity = 0;
remainingAttendeeCapacity = 0;
showRemainingAttendeeCapacity = false;
anonymousParticipation = false;
hideOrganizerWhenGroupEvent = false;
offers: IOffer[] = [];
participationConditions: IParticipationCondition[] = [];
attendees: string[] = [];
program = "";
commentModeration = CommentModeration.ALLOW_ALL;
showParticipationPrice = false;
showStartTime = true;
showEndTime = true;
}
export class EventModel implements IEvent {
id?: string;
@ -255,7 +171,7 @@ export class EventModel implements IEvent {
comments: IComment[] = [];
attributedTo?: IActor = new Actor();
attributedTo?: IGroup = new Group();
organizerActor?: IActor = new Actor();
@ -323,7 +239,6 @@ export class EventModel implements IEvent {
phoneAddress: this.phoneAddress,
physicalAddress: this.physicalAddress,
options: this.options,
// organizerActorId: this.organizerActor && this.organizerActor.id ? this.organizerActor.id : null,
attributedToId: this.attributedTo && this.attributedTo.id ? this.attributedTo.id : null,
contacts: this.contacts.map(({ id }) => ({
id,
@ -331,23 +246,3 @@ export class EventModel implements IEvent {
};
}
}
interface IEventEditJSON {
id?: string;
title: string;
description: string;
beginsOn: string;
endsOn: string | null;
status: EventStatus;
visibility: EventVisibility;
joinOptions: EventJoinOptions;
draft: boolean;
picture: IPicture | { pictureId: string } | null;
attributedToId: string | null;
onlineAddress?: string;
phoneAddress?: string;
physicalAddress?: IAddress;
tags: string[];
options: IEventOptions;
contacts: { id?: string }[];
}

View File