Commit cfe76b8d authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #14527 TIME 0:10 set the email when the sender is of type user

parent b60a7ed2
......@@ -99,7 +99,7 @@ class UserController
public function getById(Request $request, Response $response, array $args)
{
$user = UserModel::getById(['id' => $args['id'], 'select' => ['id', 'firstname', 'lastname', 'status']]);
$user = UserModel::getById(['id' => $args['id'], 'select' => ['id', 'firstname', 'lastname', 'status', 'mail']]);
if (empty($user)) {
return $response->withStatus(400)->withJson(['errors' => 'User does not exist']);
}
......
......@@ -459,28 +459,54 @@ export class SentResourcePageComponent implements OnInit {
}
if (!this.functions.empty(this.resourceData.senders)) {
this.resourceData.senders.forEach((sender: any) => {
this.setSender(sender.id);
this.setSender(sender);
});
}
}
setSender(id: number) {
this.http.get(`../rest/contacts/${id}`).pipe(
tap((data: any) => {
if (!this.functions.empty(data.email)) {
this.recipients.push(
{
label: this.contactService.formatContact(data),
email: data.email
setSender(sender: any) {
switch (sender.type) {
case 'contact':
this.http.get(`../rest/contacts/${sender.id}`).pipe(
tap((data: any) => {
if (!this.functions.empty(data.email)) {
this.recipients.push(
{
label: this.contactService.formatContact(data),
email: data.email
}
);
}
);
}
}),
catchError((err) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
}),
catchError((err) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
break;
case 'user':
this.http.get(`../rest/users/${sender.id}`).pipe(
tap((data: any) => {
if (!this.functions.empty(data.mail)) {
this.recipients.push(
{
label: this.contactService.formatContact(data),
email: data.mail
}
);
}
}),
catchError((err) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
break;
default:
break;
}
}
getUserEmails() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment