Clyde/frontend/src/rest/msg.js

83 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-03-22 13:54:52 +01:00
/*******************************************************
* 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({});
2024-03-22 13:54:52 +01:00
/**
* @return array of
* - id
* - name
* - members
*/
2024-03-22 13:54:52 +01:00
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);
2024-03-22 13:54:52 +01:00
}
export async function createDiscussion(name){
restPost("/discussion", {name: name});
}
export async function invite(id, regNo){
restPost("/discussion/"+ id+ "/invite", {user: regNo});
}