merge chat

This commit is contained in:
Peter Maquiran
2024-09-13 12:27:39 +01:00
471 changed files with 17419 additions and 53900 deletions
-64
View File
@@ -1,64 +0,0 @@
import { AES, SHA1, enc } from "crypto-js";
import { environment } from 'src/environments/environment'
function prefix() {
return environment.version.lastCommitNumber + environment.id+"-";
}
export function GET({key, instance}) {
if(environment.storageProduction) {
try {
const newKey = prefix() + SHA1(key).toString()
const cipherText = localStorage.getItem(newKey)
const bytes = AES.decrypt(cipherText, newKey)
var decryptedData = bytes.toString(enc.Utf8);
const restoredData = JSON.parse(decryptedData)
Object.assign(instance, restoredData);
return restoredData
} catch(error) {
console.log(error)
return {}
}
} else {
const newKey = prefix() + key
const restoredData = JSON.parse(localStorage.getItem(newKey))
Object.assign(instance, restoredData);
return restoredData
}
}
export function SAVE({key, instance, dataToSave}) {
if(environment.storageProduction) {
const newKey = prefix() + SHA1(key).toString()
const stringifyData = JSON.stringify(dataToSave)
const cipherText = AES.encrypt(stringifyData, newKey).toString();
localStorage.setItem(newKey, cipherText)
} else {
const stringifyData = JSON.stringify(dataToSave)
const newKey = prefix() + key
localStorage.setItem(newKey, stringifyData)
}
}
export function DELETE({key, instance}) {
if(environment.storageProduction) {
const newKey = prefix() + SHA1(key).toString()
localStorage.removeItem(newKey)
} else {
const newKey = prefix() + key
localStorage.removeItem(newKey)
}
}
-116
View File
@@ -1,116 +0,0 @@
//import { models } from 'beast-orm'
import { environment } from 'src/environments/environment'
import { models } from 'src/plugin/src'
const { ArrayField, JsonField} = models.indexedDB.fields
export class MessageModel extends models.Model {
channels = ArrayField()
mentions = ArrayField()
msg = models.CharField()
sendAttempt = models.IntegerField()
rid = models.CharField()
t = models.CharField({default:'', blank: true})
ts = JsonField({blank:true})
u = JsonField()
_id = models.CharField({blank:true})
origin = models.CharField({blank:true})
_updatedAt = models.IntegerField()
messageSend = models.BooleanField()
offline = models.BooleanField()
hasFile = models.BooleanField({blank:true})
viewed = ArrayField({blank:true})
received = ArrayField({blank:true})
localReference = models.CharField({blank:true, unique: true})
attachments = ArrayField({blank:true})
file = JsonField({blank:true})
UploadAttachmentsTemp = models.IntegerField()
async getAttachments() {
console.log('this[id]', this['id'])
const _attachments = await attachments.filter({messageId: this['id']}).execute()
return _attachments[0]
}
}
export class attachments extends models.Model {
messageId = models.IntegerField()
attachments = ArrayField({blank:true})
file = JsonField({blank:true})
}
export class DeleteMessageModel extends models.Model {
messageId = models.CharField()
rid = models.CharField()
u = JsonField()
needToReceiveBy = ArrayField()
}
models.register({
databaseName: 'chat-storage'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
type: 'indexedDB',
version: 11,
models: [MessageModel, DeleteMessageModel, attachments]
})
// // acçoes
export class ActionModel extends models.Model{
static $tableName = 'ActionModel11'
ProcessId = models.IntegerField({unique: true})
Description = models.CharField()
Detail = models.CharField()
DateBegin = models.CharField()
DateEnd = models.CharField()
ActionType = models.CharField()
}
export class PublicationFolderModel extends models.Model{
DateBegin = models.CharField()
Description = models.CharField()
Detail = models.CharField()
}
export class PublicationDetailsModel extends models.Model{
DateIndex = models.CharField()
DocumentId = models.IntegerField({unique: true})
ProcessId = models.CharField()
Title = models.CharField()
Message = models.CharField()
DatePublication = models.CharField()
OriginalFileName = models.CharField()
FileBase64 = models.CharField()
FileExtension = models.CharField()
OrganicEntityId = models.IntegerField()
}
export class WebtrixUserModel extends models.Model {
FullName = models.CharField()
Role = models.CharField()
}
models.register({
databaseName: 'webtrix'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
type: 'indexedDB',
version: 1,
models: [WebtrixUserModel]
})
models.register({
databaseName: 'actions'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
type: 'indexedDB',
version: 14,
models: [PublicationDetailsModel, ActionModel, PublicationFolderModel]
})
window["MessageModel"] = MessageModel
-390
View File
@@ -1,390 +0,0 @@
interface Ts {
$date: any;
}
interface U {
_id: string;
username: string;
name: string;
}
interface UpdatedAt {
$date: any;
}
interface Attachment {
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;
}
interface EditedAt {
$date: number;
}
interface EditedBy {
_id: string;
username: string;
}
interface Ts2 {
$date: number;
}
interface U2 {
_id: string;
username: string;
name: string;
}
interface UpdatedAt2 {
$date: number;
}
interface FirstUnread {
_id: string;
rid: string;
msg: string;
ts: Ts2;
u: U2;
_updatedAt: string;
mentions: any[];
channels: any[];
}
export interface Message {
customFields:any;
_id: string;
id: null | string;
rid: string;
msg: string;
ts: Ts;
sendAttempt?: number
u: U;
from: 'Offline'|'History'|'stream'| 'send'
t: string;
origin: 'history' | 'stream' | 'local'
_updatedAt: '';
mentions: any[];
channels: any[];
attachments: Attachment[];
file: File;
editedAt: EditedAt;
editedBy: EditedBy;
urls: any[];
temporaryData: object
localReference?: string,
viewed: string[],
received: string[],
delate: boolean,
delateRequest: boolean
attachmentsModelData: {
fileBase64: string
}
hasFile: boolean
UploadAttachmentsTemp: number
}
export interface Lm {
$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[];
}
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;
}
export interface DeletedAt {
$date: any;
}
export interface Remove {
_id: string;
_deletedAt: DeletedAt;
}
export interface Result {
update: Update[];
remove: Remove[];
}
export interface Rooms {
msg: string;
id: string;
result: Result;
}
export interface ChatMessage {
msg: string;
id: string;
result: Message
}
export interface chatHistory {
msg: string;
id: string;
result: {
messages: Message[];
firstUnread: FirstUnread;
unreadNotLoaded: number;
};
}
interface Ts {
$date: any;
}
interface U {
_id: string;
username: string;
name: string;
}
interface UpdatedAt {
$date: any;
}
interface Attachment {
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;
}
interface EditedAt {
$date: number;
}
interface EditedBy {
_id: string;
username: string;
}
interface Ts2 {
$date: number;
}
interface U2 {
_id: string;
username: string;
name: string;
}
interface UpdatedAt2 {
$date: number;
}
interface FirstUnread {
_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[];
}
export interface Lm {
$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[];
}
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;
}
export interface DeletedAt {
$date: any;
}
export interface Remove {
_id: string;
_deletedAt: DeletedAt;
}
export interface Result {
update: Update[];
remove: Remove[];
}
export interface Rooms {
msg: string;
id: string;
result: Result;
}
export interface ChatMessage {
msg: string;
id: string;
result: Message
}
export interface chatHistory {
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: '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;
}
-7
View File
@@ -1,7 +0,0 @@
import { SearchDocument } from './search-document';
describe('SearchDocument', () => {
it('should create an instance', () => {
expect(new SearchDocument()).toBeTruthy();
});
});