Skip to content

Commit

Permalink
Testing smt new
Browse files Browse the repository at this point in the history
  • Loading branch information
Gijsdeman committed Aug 19, 2023
1 parent 54b1f7d commit 0e8a8b0
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 31 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"dependencies": {
"@types/node": "^20.5.0",
"axios": "^1.4.0",
"class-transformer": "^0.5.1",
"ldapts": "^6.0.0",
"mysql": "^2.18.1",
"reflect-metadata": "^0.1.13",
"replace-in-file": "^7.0.1",
"sqlite3": "^5.1.6",
"ts-mailcow-api": "^0.8.4",
Expand Down
118 changes: 87 additions & 31 deletions src/mailcowDB.ts
Original file line number Diff line number Diff line change
@@ -1,96 +1,152 @@
import { DataSource } from 'typeorm';
import { ContainerConfig } from './types';
import 'reflect-metadata';
import { plainToClass } from 'class-transformer';

// Connection options for the DB
let dataSource;

/**
* Initialize database connection. Setup database if it does not yet exist
*/
export async function initializeMailcowDB(config: ContainerConfig): Promise<void> {
dataSource = new DataSource({
type: 'mariadb',
host: '172.22.1.251',
port: 3306,
username: 'mailcow',
password: config.DB_PASSWORD,
database: 'mailcow',
});

await dataSource.initialize()
.catch((error) => {
console.log(error);
});

const test = await dataSource
.createQueryBuilder()
.select('c_defaults')
.from('sogo_user_profile', 'profile')
.where('c_uid = "[email protected]"')
.getRawOne<Test>() as Test;

console.log(test);
console.log('=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-');
console.log(test.SOGoMailIdentities);

}

export interface Test {
export class Test {
SOGoCalendarCategoriesColors: SOGoCalendarCategoriesColors;

SOGoGravatarEnabled: number;

LocaleCode: string;

SOGoMailComposeFontSize: number;

SOGoMailReceiptNonRecipientAction: string;

SOGoDayStartTime: string;

SOGoAlternateAvatar: string;

SOGoLoginModule: string;

SOGoLDAPGroupExpansionEnabled: number;

SOGoCalendarCategories: string[];

SOGoTOTPEnabled: number;

emailSeparatorKeys: number[];

SOGoDayEndTime: string;

SOGoMailComposeMessageType: string;

SOGoCalendarWeekdays: string[];

hasActiveExternalSieveScripts: number;

SOGoShortDateFormat: string;

SOGoMailSignaturePlacement: string;

SOGoMailMessageForwarding: string;

ckLocaleCode: string;

SOGoMailReceiptOutsideDomainAction: string;

Forward: Forward;

SOGoTimeZone: string;

SOGoMailReceiptAllow: string;

UserTimeZoneSecondsFromGMT: number;

SOGoMailComposeWindow: string;

SOGoTimeFormat: string;

Vacation: Vacation;

SOGoRememberLastModule: number;

SOGoCalendarTasksDefaultClassification: string;

SOGoPasswordRecoveryMode: string;

SOGoRefreshViewCheck: string;

SOGoCalendarDefaultReminder: string;

SOGoMailAutoSave: number;

SOGoMailLabelsColors: { [key: string]: string[] };

SOGoLongDateFormat: string;

SOGoMailReceiptAnyAction: string;

SOGoMailAutoMarkAsReadDelay: number;

SOGoDefaultCalendar: string;

SOGoMailReplyPlacement: string;

SOGoAppointmentSendEMailNotifications: number;

SOGoFirstWeekOfYear: string;

SOGoSelectedAddressBook: string;

SOGoCalendarEventsDefaultClassification: string;

SOGoAnimationMode: string;

SOGoPasswordRecoveryQuestion: string;

SOGoMailAddOutgoingAddresses: number;

AuxiliaryMailAccounts: any[];

SOGoFirstDayOfWeek: number;

SOGoLanguage: string;

SOGoContactsCategories: string[];

SOGoMailIdentities: SOGoMailIdentity[];

SOGoMailDisplayRemoteInlineImages: string;
}

/**
* Initialize database connection. Setup database if it does not yet exist
*/
export async function initializeMailcowDB(config: ContainerConfig): Promise<void> {
dataSource = new DataSource({
type: 'mariadb',
host: '172.22.1.251',
port: 3306,
username: 'mailcow',
password: config.DB_PASSWORD,
database: 'mailcow',
});

await dataSource.initialize()
.catch((error) => {
console.log(error);
});

const test = await dataSource
.createQueryBuilder()
.select('c_defaults')
.from(Test, 'sogo_user_profile')
.where('c_uid = "[email protected]"')
.getOneOrFail();

console.log(test);
console.log('=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-');
console.log(test.SOGoMailIdentities);

}


export interface Forward {
forwardAddress: any[];
}
Expand Down

0 comments on commit 0e8a8b0

Please sign in to comment.