diff --git a/.gitignore b/.gitignore
index 9c25768b9..5528da384 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,7 +35,7 @@ npm-debug.log*
# Custom
/package-lock.json
-
+
src/app/architect/
src/environments/environment.e2e.ts
.env
@@ -52,4 +52,4 @@ node_modules_
node_modules__
plugins_
ios
-src/plugin/beast-orm/
\ No newline at end of file
+src/plugin/beast-orm
diff --git a/android/app/src/main/AndroidManifest.xml.orig b/android/app/src/main/AndroidManifest.xml.orig
new file mode 100644
index 000000000..66301e3a7
--- /dev/null
+++ b/android/app/src/main/AndroidManifest.xml.orig
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/assets/capacitor.config.json b/android/app/src/main/assets/capacitor.config.json
index 2399c4927..2b001f42e 100644
--- a/android/app/src/main/assets/capacitor.config.json
+++ b/android/app/src/main/assets/capacitor.config.json
@@ -16,5 +16,8 @@
"sound"
]
}
+ },
+ "server": {
+ "url": "http://192.168.1.8:8100"
}
}
diff --git a/android/app/src/main/java/com/capacitorjs/app/testapp/MainActivity.java b/android/app/src/main/java/com/capacitorjs/app/testapp/MainActivity.java
new file mode 100644
index 000000000..6ce0f538f
--- /dev/null
+++ b/android/app/src/main/java/com/capacitorjs/app/testapp/MainActivity.java
@@ -0,0 +1,5 @@
+package com.capacitorjs.app.testapp;
+
+import com.getcapacitor.BridgeActivity;
+
+public class MainActivity extends BridgeActivity {}
diff --git a/package-lock.json b/package-lock.json
index 9701f382d..6584646ed 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6229,6 +6229,11 @@
"tweetnacl": "^0.14.3"
}
},
+ "beast-orm": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/beast-orm/-/beast-orm-1.0.0.tgz",
+ "integrity": "sha512-wSholUbFMteq50U3QM0o4H3xY9IpevpG9MPlq0ZK8yRtRkIuKf/YoZW4QUwFOfY72PJbNzp68z7Ln/iFhpOxDg=="
+ },
"big-integer": {
"version": "1.6.49",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.49.tgz",
diff --git a/package.json b/package.json
index 54af0e873..958407be1 100644
--- a/package.json
+++ b/package.json
@@ -99,6 +99,7 @@
"angular-svg-icon": "^12.0.0",
"angular-tag-cloud-module": "^5.2.2",
"base64-js": "^1.5.1",
+ "beast-orm": "^1.0.0",
"bootstrap": "^4.5.0",
"build": "0.1.4",
"capacitor-voice-recorder": "^2.1.0",
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 4d545495e..fadb07747 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -12,7 +12,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { StorageService } from 'src/app/services/storage.service';
-
+import { MessageModel } from './models/beast-orm'
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
diff --git a/src/app/modals/chat-options-features/chat-options-features.page.ts b/src/app/modals/chat-options-features/chat-options-features.page.ts
index df1ece9a6..3e68404d1 100644
--- a/src/app/modals/chat-options-features/chat-options-features.page.ts
+++ b/src/app/modals/chat-options-features/chat-options-features.page.ts
@@ -120,7 +120,7 @@ export class ChatOptionsFeaturesPage implements OnInit {
}
this.chatService.sendMessage(body).subscribe(res=> {
- console.log(res);
+ // console.log(res);
},(error) => {
});
diff --git a/src/app/models/beast-orm.ts b/src/app/models/beast-orm.ts
new file mode 100644
index 000000000..49809e81f
--- /dev/null
+++ b/src/app/models/beast-orm.ts
@@ -0,0 +1,44 @@
+import { models } from 'beast-orm'
+import { AESEncrypt } from '../services/aesencrypt.service'
+
+const _AESEncrypt = new AESEncrypt()
+const { ArrayField, JsonField} = models.indexedDB.fields
+
+export class MessageModel extends models.Model {
+
+ channels = ArrayField()
+ mentions = ArrayField()
+ msg = models.CharField()
+ rid = models.CharField()
+ ts = models.CharField()
+ u = JsonField()
+ _id = models.CharField({unique:true})
+ _updatedAt = models.CharField()
+ messageSend = models.BooleanField()
+ offline = models.BooleanField()
+ viewed = ArrayField()
+ received = ArrayField()
+ localReference = models.CharField({blank:true})
+ attachments = ArrayField()
+ file = ArrayField()
+
+}
+
+export class DeleteMessageModel extends models.Model {
+
+ messageId = models.IntegerField()
+ rid = models.CharField()
+ ts = models.CharField()
+ u = JsonField()
+ needToReceiveBy = ArrayField()
+
+}
+
+
+
+models.register({
+ databaseName: 'chat-storage',
+ type: 'indexedDB',
+ version: 1,
+ models: [MessageModel, DeleteMessageModel]
+})
\ No newline at end of file
diff --git a/src/app/models/chatMethod.ts b/src/app/models/chatMethod.ts
index 6b455b237..3178d7633 100644
--- a/src/app/models/chatMethod.ts
+++ b/src/app/models/chatMethod.ts
@@ -67,6 +67,7 @@ interface FirstUnread {
export interface Message {
customFields:any;
_id: string;
+ id: null | string;
rid: string;
msg: string;
ts: Ts;
@@ -81,7 +82,11 @@ export interface Message {
editedBy: EditedBy;
urls: any[];
temporaryData: object
- localReference?: string
+ localReference?: string,
+ viewed: string[],
+ received: string[],
+ delate: boolean,
+ delateRequest: boolean
}
@@ -174,159 +179,159 @@ export interface chatHistory {
interface Ts {
- $date: any;
+ $date: any;
}
interface U {
- _id: string;
- username: string;
- name: string;
+ _id: string;
+ username: string;
+ name: string;
}
interface UpdatedAt {
- $date: any;
+ $date: any;
}
interface Attachment {
- ts: Date;
- title_link_download: boolean;
+ ts: Date;
+ title_link_download: boolean;
}
export interface File {
- type: string;
- guid: string;
- image_url: string;
- subject: string;
- start_date?: Date;
- end_date?: Date;
- venue: string;
- id: string;
+ type: string;
+ guid: string;
+ image_url: string;
+ subject: string;
+ start_date?: Date;
+ end_date?: Date;
+ venue: string;
+ id: string;
}
interface EditedAt {
- $date: number;
+ $date: number;
}
interface EditedBy {
- _id: string;
- username: string;
+ _id: string;
+ username: string;
}
interface Ts2 {
- $date: number;
+ $date: number;
}
interface U2 {
- _id: string;
- username: string;
- name: string;
+ _id: string;
+ username: string;
+ name: string;
}
interface UpdatedAt2 {
- $date: number;
+ $date: number;
}
interface FirstUnread {
- _id: string;
- rid: string;
- msg: string;
- ts: Ts2;
- u: U2;
- _updatedAt: string;
- mentions: any[];
- channels: any[];
+ _id: string;
+ rid: string;
+ msg: string;
+ ts: Ts2;
+ u: U2;
+ _updatedAt: string;
+ mentions: any[];
+ channels: any[];
}
export interface Message {
- customFields:any;
- _id: string;
- rid: string;
- msg: string;
- ts: Ts;
- u: U;
- t: string;
- _updatedAt: '';
- mentions: any[];
- channels: any[];
- attachments: Attachment[];
- file: File;
- editedAt: EditedAt;
- editedBy: EditedBy;
- urls: any[];
+ customFields:any;
+ _id: string;
+ rid: string;
+ msg: string;
+ ts: Ts;
+ u: U;
+ t: string;
+ _updatedAt: '';
+ mentions: any[];
+ channels: any[];
+ attachments: Attachment[];
+ file: File;
+ editedAt: EditedAt;
+ editedBy: EditedBy;
+ urls: any[];
}
export interface Lm {
- $date: any;
+ $date: any;
}
export interface LastMessage {
- _id: string;
- rid: string;
- msg: string;
- ts: Ts;
- u: U;
- _updatedAt: UpdatedAt2;
- mentions: any[];
- channels: any[];
- file: File;
- attachments: Attachment[];
+ _id: string;
+ rid: string;
+ msg: string;
+ ts: Ts;
+ u: U;
+ _updatedAt: UpdatedAt2;
+ mentions: any[];
+ channels: any[];
+ file: File;
+ attachments: Attachment[];
}
export interface CustomFields {
}
export interface Update {
- _id: string;
- t: string;
- usernames: string[];
- usersCount: number;
- uids: string[];
- default: boolean;
- ro: boolean;
- sysMes: boolean;
- _updatedAt: UpdatedAt;
- lm: Lm;
- lastMessage: LastMessage;
- name: string;
- fname: string;
- u: U2;
- customFields: CustomFields;
+ _id: string;
+ t: string;
+ usernames: string[];
+ usersCount: number;
+ uids: string[];
+ default: boolean;
+ ro: boolean;
+ sysMes: boolean;
+ _updatedAt: UpdatedAt;
+ lm: Lm;
+ lastMessage: LastMessage;
+ name: string;
+ fname: string;
+ u: U2;
+ customFields: CustomFields;
}
export interface DeletedAt {
- $date: any;
+ $date: any;
}
export interface Remove {
- _id: string;
- _deletedAt: DeletedAt;
+ _id: string;
+ _deletedAt: DeletedAt;
}
export interface Result {
- update: Update[];
- remove: Remove[];
+ update: Update[];
+ remove: Remove[];
}
export interface Rooms {
- msg: string;
- id: string;
- result: Result;
+ msg: string;
+ id: string;
+ result: Result;
}
export interface ChatMessage {
- msg: string;
- id: string;
- result: Message
+ msg: string;
+ id: string;
+ result: Message
}
@@ -334,44 +339,44 @@ export interface ChatMessage {
export interface chatHistory {
- msg: string;
- id: string;
- result: {
- messages: Message[];
- firstUnread: FirstUnread;
- unreadNotLoaded: number;
- };
+ msg: string;
+ id: string;
+ result: {
+ messages: Message[];
+ firstUnread: FirstUnread;
+ unreadNotLoaded: number;
+ };
}
export interface chatUser {
- _id: string;
- createdAt: Date;
- emails: {
- address: string;
- verified: boolean;
- }
- type: string;
- status: string;
- active: boolean;
- _updatedAt: Date;
- roles: string[];
- name: string;
- lastLogin: Date;
- statusConnection: string;
- utcOffset: number;
- username: string;
- __rooms: string[];
- requirePasswordChange?: boolean;
- settings: {
- preferences: {
- language: string;
- };
- };
- nickname: string;
- statusText: string;
- banners: any;
- statusDefault: string;
- language: string;
- avatarOrigin: string;
- avatarETag?: any;
+ _id: string;
+ createdAt: Date;
+ emails: {
+ address: string;
+ verified: boolean;
+ }
+ type: string;
+ status: 'online' | 'offline' | 'away' | 'busy' ;
+ active: boolean;
+ _updatedAt: Date;
+ roles: string[];
+ name: string;
+ lastLogin: Date;
+ statusConnection: string;
+ utcOffset: number;
+ username: string;
+ __rooms: string[];
+ requirePasswordChange?: boolean;
+ settings: {
+ preferences: {
+ language: string;
+ };
+ };
+ nickname: string;
+ statusText: string;
+ banners: any;
+ statusDefault: string;
+ language: string;
+ avatarOrigin: string;
+ avatarETag?: any;
}
\ No newline at end of file
diff --git a/src/app/models/message.model.ts b/src/app/models/message.model.ts
index c6993ebbc..732672370 100644
--- a/src/app/models/message.model.ts
+++ b/src/app/models/message.model.ts
@@ -1,4 +1,54 @@
-export interface Message {
- author: string;
- message: string;
- }
\ No newline at end of file
+export interface IncomingChatMessage {
+ msg: string;
+ collection: string;
+ id: string;
+ fields: {
+ args: {
+ _id: string;
+ rid: string;
+ localReference: string;
+ msg: string;
+ file?: any;
+ ts: {
+ $date: number;
+ };
+ u: {
+ _id: string;
+ username: string;
+ name: string;
+ };
+ _updatedAt: {
+ $date: number;
+ };
+ mentions: any[];
+ channels: any[];
+ } [];
+ }
+ eventName: string;
+
+};
+
+export interface ChatMessageInterface {
+ _id: string;
+ rid: string;
+ localReference: string;
+ msg: string;
+ file?: any;
+ ts: number;
+ u: {
+ _id: string;
+ username: string;
+ name: string;
+ };
+ _updatedAt: number;
+ mentions: any[];
+ channels: any[];
+};
+
+
+
+
+export interface falseTypingMethod{
+ method: 'viewMessage' | 'deleteMessage'
+ params: object
+}
\ No newline at end of file
diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts
index 744e95d1c..b7670bf96 100644
--- a/src/app/pages/chat/chat.page.ts
+++ b/src/app/pages/chat/chat.page.ts
@@ -20,7 +20,6 @@ import { NewGroupPage } from './new-group/new-group.page';
import { Storage } from '@ionic/storage';
import { EditGroupPage } from 'src/app/shared/chat/edit-group/edit-group.page';
import * as Rx from "rxjs/Rx";
-import { Message } from 'src/app/models/message.model';
import { Observable, Subject } from "rxjs/Rx";
import { NavigationStart, NavigationEnd, Router } from '@angular/router';
import { EventPerson } from 'src/app/models/eventperson.model';
@@ -143,10 +142,6 @@ export class ChatPage implements OnInit {
ngOnInit() {
- console.log('Rooms INDIVIDUAIS',this.wsChatMethodsService._dm);
- console.log(' ROOMS GROUP',this.wsChatMethodsService._group);
-
-
this.segment = "Contactos";
this.authService.userData$.subscribe((res: any) => {
diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html
index 4a1a20dec..17f117c9d 100644
--- a/src/app/pages/chat/group-messages/group-messages.page.html
+++ b/src/app/pages/chat/group-messages/group-messages.page.html
@@ -63,7 +63,8 @@
{{msg.duration}}
- {{msg.msg}}
+ {{msg.msg}}
+ {{msg.msg}}
{{last ? scrollToBottom() : ''}}
@@ -92,7 +93,7 @@
-->
-
+
{{msg.u.name ?? ""}}
@@ -117,7 +118,15 @@
{{file.title}}
-
+
+
+
+ {{file.title}}
+
+
+
+
+
@@ -140,7 +149,9 @@
{{msg.file.venue}}
-
+
+ Apagou a mensagem
+
Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"
@@ -190,8 +201,9 @@
-
-
+ {
+ this.scrollToBottomClicked()
+ this.showAvatar = true
+ }, 150)
+
}
ngOnInit() {
@@ -419,41 +428,64 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
}
+ base64toBlob(base64Data, contentType) {
+ contentType = contentType || '';
+ var sliceSize = 1024;
+ var byteCharacters = atob(base64Data);
+ var bytesLength = byteCharacters.length;
+ var slicesCount = Math.ceil(bytesLength / sliceSize);
+ var byteArrays = new Array(slicesCount);
+
+ for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
+ var begin = sliceIndex * sliceSize;
+ var end = Math.min(begin + sliceSize, bytesLength);
+
+ var bytes = new Array(end - begin);
+ for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
+ bytes[i] = byteCharacters[offset].charCodeAt(0);
+ }
+ byteArrays[sliceIndex] = new Uint8Array(bytes);
+ }
+ return new Blob(byteArrays, { type: contentType });
+}
+
async sendAudio(fileName) {
const roomId = this.roomId
+ let audioFile;
this.storage.get('recordData').then((recordData) => {
console.log(recordData);
+ audioFile = recordData;
if(recordData.value.recordDataBase64.includes('data:audio')){
this.audioRecorded = recordData.value.recordDataBase64;
}
else{
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`;
}
- });
//Converting base64 to blob
- const base64Response = await fetch(this.audioRecorded);
- const blob = await base64Response.blob();
-
+ const encodedData = btoa(this.audioRecorded);
+ const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
+ console.log(blob)
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/audio",
- /* "guid": '', */
+ "msDuration":audioFile.value.msDuration,
+ "mimeType":audioFile.value.mimeType,
},
attachments: [{
"title": fileName ,
- "title_link": this.audioRecorded,
"title_link_download": true,
- "type": "file"
+ "type": "audio"
}],
temporaryData: formData
})
- this.deleteRecording();
+ });
+ this.deleteRecording();
}
@@ -944,34 +976,35 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
downloadFileMsg(msg) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
- // if (msg.file.type == "application/img") {
- this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
- console.log('FILE TYPE 22', msg.file.guid)
- var name = msg.file.guid;
+ this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
+ console.log('FILE TYPE 22', msg.file.guid)
+ var name = msg.file.guid;
- if (event.type === HttpEventType.DownloadProgress) {
- //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
- console.log('FILE TYPE 33', msg.file.type)
- } else if (event.type === HttpEventType.Response) {
- if (msg.file.type == "application/img") {
+ if (event.type === HttpEventType.DownloadProgress) {
+ //this.downloadProgess = Math.round((100 * event.loaded) / event.total);
+ console.log('FILE TYPE 33', msg.file.type)
+ } else if (event.type === HttpEventType.Response) {
+ if (msg.file.type == "application/img") {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
- } else {
+ } else if (msg.file.type === 'application/pdf') {
this.downloadFile = event.body;
+ } else if (msg.file.type == 'application/audio') {
+ this.downloadFile = new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '');
}
-
msg.attachments[0] = {
image_url: this.downloadFile,
name: msg.attachments[0].name,
title: msg.attachments[0].title,
+ title_link: this.downloadFile,
title_link_download: msg.attachments[0].title_link_download,
ts: msg.attachments[0].ts
}
- this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
- }
- });
- console.log('FILE TYPE 44', this.downloadFile)
- //}
+ // save the changes to the storage
+ msg.save()
+ }
+ });
+
}
async openPreview(msg) {
@@ -994,5 +1027,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
+
+ async audioPreview(msg) {
+ console.log(msg);
+ if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
+ this.downloadFileMsg(msg)
+ } else {}
+ }
}
diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html
index b3676740b..56d82f718 100644
--- a/src/app/pages/chat/messages/messages.page.html
+++ b/src/app/pages/chat/messages/messages.page.html
@@ -1,4 +1,4 @@
-
+
+
+
@@ -24,14 +26,15 @@