Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/mail #390

Merged
merged 3 commits into from
Jul 30, 2023
Merged

Update/mail #390

merged 3 commits into from
Jul 30, 2023

Conversation

ChienNQuang
Copy link
Member

No description provided.

@ChienNQuang ChienNQuang self-assigned this Jul 28, 2023

if (request.CanView)
{
var p = "view";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p for permission LMAO!
We are in hurry so yeh...
As long as it works.

Copy link
Member

@kaitoz11 kaitoz11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really good.
But hey! It's working so i'm letting it be! We're out of time!

Comment on lines 56 to 137
public bool SendShareEntryHtmlMail(bool isDirectory, string name, string sharerName, string operation, string ownerName,
string email, string path)
{
var data = new HtmlMailData()
{
From = new From()
{
Email = _mailSettings.SenderEmail,
Name = _mailSettings.SenderName,
},
To = new To[]
{
new (){ Email = email },
},
TemplateUuid = _mailSettings.TemplateUuids.ShareEntry,
TemplateVariables = new ShareEntryTemplateVariables()
{
EntryName = name,
Operation = operation,
EntryType = isDirectory ? "Folder" : "File",
OwnerName = ownerName,
SharerName = sharerName,
Path = path
},
};

var json = JsonSerializer.Serialize(data, new JsonSerializerOptions(JsonSerializerDefaults.Web));

var client = new RestClient(_mailSettings.ClientUrl);
var request = new RestRequest
{
Method = Method.Post
};

request.AddHeader("Authorization", $"{JwtBearerDefaults.AuthenticationScheme} {_mailSettings.Token}");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", json, ParameterType.RequestBody);
var response = client.Execute(request);
return response.IsSuccessStatusCode;
}

public bool SendCreateRequestHtmlMail(string userName, string requestType, string operation, string documentName,
string reason, Guid documentId, string email)
{
var data = new HtmlMailData()
{
From = new From()
{
Email = _mailSettings.SenderEmail,
Name = _mailSettings.SenderName,
},
To = new To[]
{
new (){ Email = email },
},
TemplateUuid = _mailSettings.TemplateUuids.Request,
TemplateVariables = new CreateRequestTemplateVariables()
{
Operation = operation,
Reason = reason,
DocumentName = documentName,
UserName = userName,
Id = documentId.ToString(),
RequestType = requestType,
Path = !requestType.Equals("borrow request") ? "import/manage" : "requests"
},
};

var json = JsonSerializer.Serialize(data, new JsonSerializerOptions(JsonSerializerDefaults.Web));

var client = new RestClient(_mailSettings.ClientUrl);
var request = new RestRequest
{
Method = Method.Post
};

request.AddHeader("Authorization", $"{JwtBearerDefaults.AuthenticationScheme} {_mailSettings.Token}");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", json, ParameterType.RequestBody);
var response = client.Execute(request);
return response.IsSuccessStatusCode;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They smell! And I don't give a shit anymore! As long as it works!

@Vzart Vzart merged commit 1cf9b1f into dev Jul 30, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants