83 lines
2.3 KiB
JavaScript
83 lines
2.3 KiB
JavaScript
/*******************************************************
|
|
* File: msg.js
|
|
* Author: Anthony Debucquoy
|
|
* Scope: Extension messagerie
|
|
* Description: Messages frontend api consumer
|
|
*******************************************************/
|
|
|
|
import { restGet, restPost } from './restConsumer.js'
|
|
import { ref } from 'vue'
|
|
|
|
export const currentDiscussion = ref({});
|
|
|
|
/**
|
|
* @return array of
|
|
* - id
|
|
* - name
|
|
* - members
|
|
*/
|
|
export async function getDiscussions(){
|
|
return restGet("/discussions");
|
|
}
|
|
|
|
export async function fetchDiscussion(id){
|
|
currentDiscussion.value = {
|
|
id: id,
|
|
name: "Discussion#2",
|
|
msgs: [
|
|
{
|
|
id: 1,
|
|
author: 1,
|
|
sender: true,
|
|
attachment: null,
|
|
text: "Hello world!"
|
|
},
|
|
{
|
|
id: 2,
|
|
author: 2,
|
|
sender: false,
|
|
attachment: null,
|
|
text: "Hello What?"
|
|
},
|
|
{
|
|
id: 3,
|
|
author: 2,
|
|
sender: false,
|
|
attachment: null,
|
|
text: "You morron"
|
|
},
|
|
{
|
|
id: 4,
|
|
author: 1,
|
|
sender: true,
|
|
attachment: null,
|
|
text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
|
},
|
|
// {
|
|
// id: 5,
|
|
// author: 1,
|
|
// sender: true,
|
|
// attachment: null,
|
|
// text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
|
// },
|
|
{
|
|
id: 6,
|
|
author: 2,
|
|
sender: false,
|
|
attachment: null,
|
|
text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
|
}
|
|
]
|
|
}
|
|
// currentDiscussion.value = restGet("/discussion/" + id);
|
|
}
|
|
|
|
export async function createDiscussion(name){
|
|
return restPost("/discussion", {name: name});
|
|
}
|
|
|
|
|
|
export async function invite(id, regNo){
|
|
restPost("/discussion/"+ id+ "/invite", {user: regNo});
|
|
}
|