Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/api/behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ default:
- '%paths.base%/doc/features/messages/'
contexts:
- Test\Acceptance\Context\Message
forums:
paths:
- '%paths.base%/doc/features/forums/'
contexts:
- Test\Acceptance\Context\Forum

extensions:
FriendsOfBehat\SymfonyExtension:
Expand Down
27 changes: 27 additions & 0 deletions apps/api/config/doctrine/mapping/Model/Forum.Forum.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
Domain\Model\Forum\Forum:
type: entity

embedded:
id:
class: Domain\Identity\Identifier
columnPrefix: false

fields:
name:
type: string
createdAt:
type: datetime_immutable
updatedAt:
type: datetime_immutable

manyToOne:
station:
targetEntity: Domain\Model\Station
inversedBy: forums
joinColumn:
nullable: false
onDelete: CASCADE

lifecycleCallbacks:
preUpdate: [ 'touch' ]
31 changes: 31 additions & 0 deletions apps/api/config/doctrine/mapping/Model/Forum.Post.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
Domain\Model\Forum\Post:
type: entity

embedded:
id:
class: Domain\Identity\Identifier
columnPrefix: false

fields:
content:
type: string
createdAt:
type: datetime_immutable
updatedAt:
type: datetime_immutable

manyToOne:
author:
targetEntity: Domain\Model\User
joinColumn:
nullable: false
onDelete: CASCADE
subject:
targetEntity: Domain\Model\Forum\Subject
joinColumn:
nullable: false
onDelete: CASCADE

lifecycleCallbacks:
preUpdate: [ 'touch' ]
26 changes: 26 additions & 0 deletions apps/api/config/doctrine/mapping/Model/Forum.Subject.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
Domain\Model\Forum\Subject:
type: entity

embedded:
id:
class: Domain\Identity\Identifier
columnPrefix: false

fields:
title:
type: string
createdAt:
type: datetime_immutable
updatedAt:
type: datetime_immutable

manyToOne:
forum:
targetEntity: Domain\Model\Forum\Forum
joinColumn:
nullable: false
onDelete: CASCADE

lifecycleCallbacks:
preUpdate: [ 'touch' ]
4 changes: 4 additions & 0 deletions apps/api/config/doctrine/mapping/Model/Station.orm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Domain\Model\Station:
targetEntity: Channel
mappedBy: station
cascade: [ persist,remove ]
forums:
targetEntity: Domain\Model\Forum\Forum
mappedBy: station
cascade: [ persist, remove ]

manyToMany:
users:
Expand Down
3 changes: 3 additions & 0 deletions apps/api/config/services/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ services:
Domain\Repository\Messages: '@Application\Repository\Messages'
Domain\Repository\Users: '@Application\Repository\Users'
Domain\Repository\Invitations: '@Application\Repository\Invitations'
Domain\Repository\Forums: '@Application\Repository\Forums'
Domain\Repository\Subjects: '@Application\Repository\Subjects'
Domain\Repository\Posts: '@Application\Repository\Posts'

## Events Implementations

Expand Down
15 changes: 15 additions & 0 deletions apps/api/doc/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ paths:
/channel/{id}/messages: { $ref: ./paths/messages.yml }
/message/{id}: { $ref: ./paths/message.yml }

# Forum
/station/{id}/forums: { $ref: ./paths/forums.yml }

# Subject
/forum/{id}/subjects: { $ref: ./paths/subjects.yml }

# Posts
/subject/{id}/posts: { $ref: ./paths/posts.yml }

components:
parameters:
id:
Expand Down Expand Up @@ -85,3 +94,9 @@ components:
$ref: ./schema/user-item.json
Invitation:
$ref: ./schema/invitation-item.json
Forum:
$ref: ./schema/forum-item.json
Subject:
$ref: ./schema/subject-item.json
Post:
$ref: ./schema/post-item.json
25 changes: 25 additions & 0 deletions apps/api/doc/features/forums/create.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Create Forum
In order to manage forums in station
As an admin
I need to be able to create new forum

Scenario: Create new forum as admin
Given I am an admin
And There is the station "Test"
When I create a new forum for the station with
| name |
| Forum |
Then I should be notified that the forum is created

Scenario: Not authorized to create forum as regular user
Given I am a user
And There is the station "Test"
When I create a new forum for the station with
| name |
| Forum |
Then I should be notified that I'm not authorized for operation "forum:create"

Scenario: Fail to create forum in non existing station
Given I am an admin
When I create a forum "Random" for non existing station
Then I should be notified that the station does not exists
19 changes: 19 additions & 0 deletions apps/api/doc/features/forums/list.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: List Forums
In order to participate at forums discussions
As a regular user
I need to be able to list forums from station

Scenario: List forums of a station
Given I am a user
And There is the station "Test"
And I am member of the station
And There is multiple forums in the station
When I list all forums of the station
Then I should see the list of all forums in this station

Scenario: Not authorized to list forums of station without being member
Given I am a user
And There is the station "Company"
But I am not member of the station
When I list all forums of the station
Then I should be notified that I'm not authorized for operation "station:list_forums"
55 changes: 55 additions & 0 deletions apps/api/doc/paths/forums.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
get:
tags: [ Forum ]
summary: List forums of station
operationId: get-forums
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
responses:
200:
description: OK
content:
application/json:
schema:
$ref: ../schema/forums.json
examples:
forums:
summary: An array of forums
values: [
{
id: "4b86105b-24ee-4510-af48-e52d86e7139d",
name: "Questions/Answers",
station: {
id: "4b86105b-24ee-4510-af48-e45d86e8739d",
name: "Company"
}
},
{
id: "994b7a18-7746-4b5f-b395-9539649b0898",
name: "Discussions",
station: {
id: "4b86105b-24ee-4510-af48-e45d86e8739d",
name: "Company"
}
}
]
404: { $ref: '../api.yml#/components/responses/notfound' }

post:
tags: [ Forum ]
summary: Create forum in station
operationId: post-forums
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
requestBody:
content:
application/json:
schema:
$ref: ../schema/input/input-forum.json
responses:
201:
description: Created
content:
application/json:
schema:
$ref: ../schema/forum-item.json
400: { $ref: '../api.yml#/components/responses/invalid' }
404: { $ref: '../api.yml#/components/responses/notfound' }
51 changes: 51 additions & 0 deletions apps/api/doc/paths/posts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
get:
tags: [ Post ]
summary: List posts in subject from forum
operationId: get-posts
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
responses:
200:
description: OK
content:
application/json:
schema:
$ref: ../schema/posts.json
examples:
subjects:
summary: An array of posts
values: [
{
id: "4b86105b-24ee-4510-af48-e52d86e7139d",
content: "I have some trouble, please help",
author: {
id: "4b86105b-24ee-4510-af48-e45d86e8739d",
name: "John Doe"
},
subject: {
id: "4b86105b-24ee-4510-af48-e45d86e8739d",
title: "Questions/Answers"
}
}
]
404: { $ref: '../api.yml#/components/responses/notfound' }

post:
tags: [ Post ]
summary: Create post in subject from forum
operationId: post-posts
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
requestBody:
content:
application/json:
schema:
$ref: ../schema/input/input-post.json
responses:
201:
description: Created
content:
application/json:
schema:
$ref: ../schema/post-item.json
400: { $ref: '../api.yml#/components/responses/invalid' }
404: { $ref: '../api.yml#/components/responses/notfound' }
47 changes: 47 additions & 0 deletions apps/api/doc/paths/subjects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
get:
tags: [ Subject ]
summary: List subjects of forum
operationId: get-subjects
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
responses:
200:
description: OK
content:
application/json:
schema:
$ref: ../schema/subjects.json
examples:
subjects:
summary: An array of subjects
values: [
{
id: "4b86105b-24ee-4510-af48-e52d86e7139d",
title: "Error while compiling",
forum: {
id: "4b86105b-24ee-4510-af48-e45d86e8739d",
name: "Questions/Answers"
}
}
]
404: { $ref: '../api.yml#/components/responses/notfound' }

post:
tags: [ Subject ]
summary: Create subject in forum
operationId: post-subjects
parameters: [{ $ref: '../api.yml#/components/parameters/id' }]
requestBody:
content:
application/json:
schema:
$ref: ../schema/input/input-subject.json
responses:
201:
description: Created
content:
application/json:
schema:
$ref: ../schema/subject-item.json
400: { $ref: '../api.yml#/components/responses/invalid' }
404: { $ref: '../api.yml#/components/responses/notfound' }
33 changes: 33 additions & 0 deletions apps/api/doc/schema/forum-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://chatterer.io/forum-item.json",
"additionalProperties": false,
"title": "Forum item",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date"
},
"updatedAt": {
"type": "string",
"format": "date"
},
"station": {
"$ref": "./station-lite.json"
}
},
"required": [
"id",
"name",
"station",
"createdAt",
"updatedAt"
]
}
Loading