Merge pull request #136 from DeimosPr4/issue-fix-estilo-correos

fix estilo de correos
This commit is contained in:
Maria Sánchez 2022-07-28 20:50:03 -06:00 committed by GitHub
commit 2b9d8ab329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1524 additions and 3729 deletions

View File

@ -22,7 +22,7 @@ export class EmailController {
@MessagePattern({ cmd: 'html' })
async postHTMLEmail(@Payload() user: any) {
const url = "http://localhost:3000/";
const image = "images/email.ong";
const image = "images/email.png";
var response = await this.mailService.sendMail({
to: user["email"],
from: "mbonilla.guti@gmail.com",
@ -48,7 +48,7 @@ export class EmailController {
async emailCreateUserAdmin(@Payload() user: any) {
const url = "http://localhost:3000/";
const image = "images/email.png";
const logo = "images/Logo Katoikia.svg";
const logo = "images/Logo Katoikia.png";
var response = await this.mailService.sendMail({
to: user["email"],
from: "mbonilla.guti@gmail.com",
@ -69,8 +69,8 @@ export class EmailController {
cid: 'image_email' //my mistake was putting "cid:logo@cid" here!
},
{
filename: 'Logo Katoikia.svg',
path: __dirname + '/mails/images/Logo Katoikia.svg',
filename: 'Logo_Katoikia.png',
path: __dirname + '/mails/images/Logo_Katoikia.png',
cid: 'logoKatoikia' //my mistake was putting "cid:logo@cid" here!
}
]

View File

@ -10,6 +10,10 @@
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"
integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- CSS Reset : BEGIN -->
<style>
@ -119,7 +123,7 @@
<!-- Progressive Enhancements : BEGIN -->
<style>
.primary {
background: #30e3ca;
background: #D7A86E;
}
.bg_white {
@ -150,7 +154,7 @@
.btn.btn-primary {
border-radius: 5px;
background: #30e3ca;
background: #D7A86E;
color: #ffffff;
}
@ -185,6 +189,7 @@
color: #000000;
margin-top: 0;
font-weight: 400;
margin-bottom: 12px;
}
body {
@ -192,11 +197,11 @@
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, .4);
color: rgba(0, 0, 0, 0.808);
}
a {
color: #30e3ca;
color: #D7A86E;
}
table {}
@ -208,7 +213,7 @@
}
.logo h1 a {
color: #30e3ca;
color: #D7A86E;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
@ -221,7 +226,7 @@
}
.hero .text {
color: rgba(0, 0, 0, .3);
color: rgba(0, 0, 0, 0.884);
}
.hero .text h2 {
@ -239,7 +244,7 @@
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
color: #D7A86E;
}
@ -272,7 +277,7 @@
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
background: #D7A86E;
margin: 0 auto;
}
@ -281,7 +286,6 @@
}
.heading-section-white h2 {
font-family:
line-height: 1;
padding-bottom: 0;
}
@ -356,17 +360,23 @@
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center;">
<td class="logo" style="text-align: right;">
<img src="cid:logoLatoikia" alt="Logo Katoikia"
style="width: 60px; max-width: 60px; height: auto; margin: auto; display: block; float: right;">
</td>
<td class="logo" style="text-align: left;">
<h1><a href="#">Katoikia</a></h1>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
<img src="cid:logoLatoikia" alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">
<img src="cid:image_email" alt="Logo Katoikia"
style="width: 150px; max-width: 300px; height: auto; margin: auto; display: block;">
</td>
</tr><!-- end tr -->
<tr>
@ -375,16 +385,22 @@
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h2>Hola, {{ name }}</h2>
<h2>Ha sido registrado como un Administrador General del sitio web Katoikia</h2>
<h3>Fecha de registro {{date_entry}}</h3>
<h2> Hola , {{ name }} <i class="fa-regular fa-face-smile-wink"
style="color:#D7A86E; font-size: 0.8em; margin-left: 20px;"></i></h2>
<h3>Ha sido registrado como un Administrador General del sitio web Katoikia</h3>
<h4><i class="fa-solid fa-calendar-day"
style="color:#D7A86E; margin-right: 10px;"></i> Fecha de registro
{{date_entry}}</h4>
</div>
<div class="text" style="padding: 0 4em; text-align: left;">
<h3>Estas son sus credenciales:</h3>
<ul>
<li>Correo electronico: {{email}}</li>
<li>Password: {{password}}</li>
</ul>
<h3>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus benefucuin</h3>
<p><i class="fa-regular fa-envelope" style="color:#D7A86E; margin-right: 10px;"></i> Correo electronico: {{email}}</p>
<p><i class="fa-solid fa-key" style="color:#D7A86E; margin-right: 10px;"></i> Password: {{password}}</p>
</div>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h3>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus
beneficios</h3>
<p><a href="{{ url }}" class="btn btn-primary">Iniciar sesión</a></p>
</div>
</td>
@ -392,46 +408,45 @@
</table>
</td>
</tr><!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px;">
<!-- <h3 class="heading">About</h3>
<p>A small river named Duden flows by their place and supplies it with
the necessary regelialia.</p>
-->
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>Katoikia es su compañero más cercano para poder estar en contacto con sus vecinos y conocer sobre los mejores anuncios sobre su comunidad.</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px;">
<!-- <h3 class="heading">Informacion de contacto</h3>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span class="text">203 Fake St. Mountain View, San Francisco,
California, USA</span></li>
<li><span class="text">+2 392 3929 210</span></a></li>
<li><span href="mailto:katoikiaapp@gmail.com" class="text">katoikiaapp@gmail.com</span></li>
</ul>
-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><!-- end: tr -->
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="http://localhost:3000" style="color: rgba(0, 0, 0, 0.8)">katoikiaapp.org</a></p>
</td>
</table>

View File

@ -10,6 +10,10 @@
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"
integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- CSS Reset : BEGIN -->
<style>
@ -119,7 +123,7 @@
<!-- Progressive Enhancements : BEGIN -->
<style>
.primary {
background: #30e3ca;
background: #D7A86E;
}
.bg_white {
@ -150,7 +154,7 @@
.btn.btn-primary {
border-radius: 5px;
background: #30e3ca;
background: #D7A86E;
color: #ffffff;
}
@ -185,6 +189,7 @@
color: #000000;
margin-top: 0;
font-weight: 400;
margin-bottom: 12px;
}
body {
@ -192,11 +197,11 @@
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, .4);
color: rgba(0, 0, 0, 0.808);
}
a {
color: #30e3ca;
color: #D7A86E;
}
table {}
@ -208,7 +213,7 @@
}
.logo h1 a {
color: #30e3ca;
color: #D7A86E;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
@ -221,7 +226,7 @@
}
.hero .text {
color: rgba(0, 0, 0, .3);
color: rgba(0, 0, 0, 0.884);
}
.hero .text h2 {
@ -239,7 +244,7 @@
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
color: #D7A86E;
}
@ -272,7 +277,7 @@
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
background: #D7A86E;
margin: 0 auto;
}
@ -281,7 +286,6 @@
}
.heading-section-white h2 {
font-family:
line-height: 1;
padding-bottom: 0;
}
@ -356,17 +360,23 @@
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center;">
<td class="logo" style="text-align: right;">
<img src="cid:logoKatoikia" alt="Logo Katoikia"
style="width: 60px; max-width: 60px; height: auto; margin: auto; display: block; float: right;">
</td>
<td class="logo" style="text-align: left;">
<h1><a href="#">Katoikia</a></h1>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
<img src="cid:logoKatoikia" alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">
<img src="cid:image_email" alt="Logo Katoikia"
style="width: 150px; max-width: 300px; height: auto; margin: auto; display: block;">
</td>
</tr><!-- end tr -->
<tr>
@ -375,16 +385,27 @@
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h2>Hola, {{ name }}</h2>
<p>Ha sido registrado como un Administrador de la Comunidad `{{community_name}}`</p>
<p>Fecha de registro: {{date_entry}}</p>
<h2> Hola , {{ name }} <i class="fa-regular fa-face-smile-wink"
style="color:#D7A86E; font-size: 0.8em; margin-left: 20px;"></i></h2>
<h3>Ha sido registrado como un Administrador de la Comunidad `{{community_name}}`
</h3>
<h4><i class="fa-solid fa-calendar-day"
style="color:#D7A86E; margin-right: 10px;"></i> Fecha de registro
{{date_entry}}</h4>
</div>
<div class="text" style="padding: 0 4em; text-align: left;">
<h3>Estas son sus credenciales:</h3>
<ul>
<li></p>Correo electronico: {{email}}</p></li>
<li><p>>Password: {{password}}</p></li>
</ul>
<p>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus benefucuin</p>
<p><i class="fa fa-regular fa-envelope"
style="color:#D7A86E; margin-right: 10px;"></i> Correo electronico:
{{email}}</p>
<p><i class="fa-solid fa-key" style="color:#D7A86E; margin-right: 10px;"></i>
Password: {{password}}</p>
</div>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h3>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus
beneficios</h3>
<p><a href="{{ url }}" class="btn btn-primary">Iniciar sesión</a></p>
</div>
</td>
@ -392,46 +413,47 @@
</table>
</td>
</tr><!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px;">
<!-- <h3 class="heading">About</h3>
<p>A small river named Duden flows by their place and supplies it with
the necessary regelialia.</p>
-->
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>Katoikia es su compañero más cercano para poder estar en contacto con sus
vecinos y conocer sobre los mejores anuncios sobre su comunidad.</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px;">
<!-- <h3 class="heading">Informacion de contacto</h3>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span class="text">203 Fake St. Mountain View, San Francisco,
California, USA</span></li>
<li><span class="text">+2 392 3929 210</span></a></li>
<li><span href="mailto:katoikiaapp@gmail.com"
class="text">katoikiaapp@gmail.com</span></li>
</ul>
-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><!-- end: tr -->
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="http://localhost:3000" style="color: rgba(0, 0, 0, 0.8)">katoikiaapp.org</a></p>
</td>
</table>

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

File diff suppressed because it is too large Load Diff

View File

@ -29,10 +29,12 @@
"@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.1",
"buffer": "^5.7.1",
"class-validator": "^0.13.2",
"cors": "^2.8.5",
"crypto-browserify": "^3.12.0",
"md5-typescript": "^1.0.5",
"mongoose": "^6.4.1",
"mongoose-unique-validator": "^3.1.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",

View File

@ -0,0 +1,14 @@
import { ArgumentsHost, Catch, ConflictException, ExceptionFilter } from '@nestjs/common';
import { MongoError } from 'mongodb';
@Catch(MongoError)
export class MongoExceptionFilter implements ExceptionFilter {
catch(exception: MongoError, host: ArgumentsHost) {
switch (exception.code) {
case 11000:
console.log('llave duplicada')
// duplicate exception
// do whatever you want here, for instance send error to client
}
}
}

View File

@ -16,11 +16,12 @@ import { UsersModule } from './users/users.module';
},
]),
MongooseModule.forRoot(
`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_usuarios?retryWrites=true&w=majority`,
`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_usuarios?retryWrites=true&w=majority`
),
UsersModule,
],
controllers: [],
providers: [],
})
export class AppModule {}
export class AppModule { }

View File

@ -0,0 +1,30 @@
import { Injectable } from "@nestjs/common";
import { Model } from 'mongoose';
import { User, UserDocument } from '../schemas/user.schema';
import { InjectModel } from '@nestjs/mongoose';
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from "class-validator";
@ValidatorConstraint({ name: 'UserExists', async: true })
@Injectable()
export class UserExistsRule implements ValidatorConstraintInterface {
constructor(
@InjectModel(User.name) private readonly userModel: Model<UserDocument>,
) {}
async validate(value: string) {
try {
await this.userModel.find({email: value});
} catch (e) {
return false;
}
return true;
}
defaultMessage(args: ValidationArguments) {
return `User doesn't exist`;
}
}

View File

@ -1,23 +1,27 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
var uniqueValidator = require('mongoose-unique-validator');
import { IsEmail, IsNotEmpty, IsString, Validate } from 'class-validator';
import { UserExistsRule } from 'src/exceptions/UserExistsRule';
export type UserDocument = User & Document;
@Schema({ collection: 'users' })
@Schema({ collection: 'users'})
export class User {
@Prop()
dni: string;
@Prop({index: true})
dni!: string;
@Prop()
@Prop({required: true})
name: string;
@Prop()
@Prop({required: true})
last_name: string;
@Prop()
@Prop({required: true, unique: true})
@Validate(UserExistsRule)
email: string;
@Prop()
@Prop({required: true, unique: true})
phone: number;
@Prop()
@ -37,3 +41,4 @@ export class User {
}
export const UserSchema = SchemaFactory.createForClass(User);
UserSchema.plugin(uniqueValidator);

View File

@ -1,7 +1,8 @@
import { Controller } from '@nestjs/common';
import { Controller, UseFilters } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { User, UserDocument } from '../schemas/user.schema';
import { UsersService } from './users.service';
import { MongoExceptionFilter } from 'src/MongoExceptionFilter';
@Controller()
export class UsersController {
@ -13,6 +14,7 @@ export class UsersController {
}
@MessagePattern({ cmd: 'createAdminSystem' })
@UseFilters(MongoExceptionFilter)
createUserAdmin(@Payload() user: UserDocument) {
return this.userService.create(user);
}

View File

@ -28,12 +28,16 @@ export class UsersService {
let password = user.password;
let passwordEncriptada = Md5.init(user.password);
user.password = passwordEncriptada;
this.userModel.create(user);
this.userModel.create(user)
let community = await this.findCommunity(user.community_id);
user.community_id = community['name'];
const pattern = { cmd: 'emailCreateUserAdminCommunity' };
const payload = { email: user['email'], password: password, name: user['name'], date_entry: user['date_entry'] };
const payload = { email: user['email'], password: password, name: user['name'],
date_entry: user['date_entry'], community_name: community['name'] };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(
@ -141,8 +145,22 @@ export class UsersService {
return this.userModel.deleteOne({ _id: id }).exec();
}
async validateEmail(email: string) {
let repo1 = this.userModel;
return new Promise<User>((resolve, reject) => {
let repo = repo1;
repo.find({ email: email }).exec((err, res) => {
if (err) {
reject(err);
} else {
if (res.length > 0) {
return res;
}
}
});
});
}
}