Skip to content

Commit

Permalink
Merge branch 'main' into YT/Feature/3365
Browse files Browse the repository at this point in the history
  • Loading branch information
yannicktrinh authored Dec 13, 2023
2 parents 794e246 + 9d67950 commit 9ccad37
Show file tree
Hide file tree
Showing 17 changed files with 551 additions and 234 deletions.
53 changes: 53 additions & 0 deletions .github/cla/4DCLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
**⚠️ WARNING!**

**Any Contributor shall sign a Contribution Licence Agreement before submitting a Contribution.**

**The CLA provides that the Contributor ("You") retains ownership on your Contribution(s) while granting 4D the legal rights to use the Contribution(s).**

**Before signing this CLA, you shall indicate below (by ticking the right box) whether you are submitting Contributions in the course of work for Your employer or not.**

**To accept and sign the CLA, you must write the text "I have read the CLA Document and I hereby sign the CLA".**

**If you do not accept the terms of the CLA, please do not write the acceptance text and do not submit any Contribution.**

I accept and agree to the terms of this Contribution License Agreement for my present and future Contributions to 4D.

---

# 4D Contribution Licence Agreement between You and 4D

## Definitions

"**4D**" refers to 4D SAS whose registered offices are at Parc les Erables – Bâtiment 4 – 66 route de Sartrouville - 78230 Le Pecq - France

"**4D Product(s)**" refers to any of the products owned or managed by 4D.

"**CLA**" refers to this Contribution License Agreement.

"**Contribution**" refers to any original work intentionally submitted by You to 4D for the purpose of contributing to, developing, add to, improve or modify the 4D Products, (i) in source or object code submitted or uploaded to 4D repositories, or (ii) in written format such as written suggestion, feedback, ideas, documentation. For the purposes of this definition, "**submitted**" means any form of electronic, verbal, or written communication sent to 4D or its representatives.

"**Contributor**" and "**You**" refer to the contribution owner signing the CLA with 4D.

## Copyright Licence

Subject to the terms and conditions of this CLA, You hereby grant to 4D a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.

## Patent Licence

Subject to the terms and conditions of this CLA, You hereby grant to the 4D a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Contribution, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the 4D Products.

## Representations and Warranties

1. You represent that each of Your Contributions is entirely Your original work. Should You wish to submit materials that are not Your original work, You may submit them if You *(a)* retain all copyright and license information that was in the materials as You received them, *(b)* expressly state, when submitting Your Contribution, that it contains materials of a third party, and identify the third party and any associated licenses or other restrictions of which You are aware.

2. You represent that You are legally entitled to grant the above license. If Your Contribution is made in the course of Your work for an employer or anyone else for whom You are acting ("employer"), or if Your employer has intellectual property rights in Your Contribution by contract or applicable law, You must secure permission from Your employer to make the Contribution before signing this CLA. In that case, the term "You" in this CLA will refer to You and the employer collectively. If You change employers in the future and desire to submit additional Contributions for the new employer, then You agree to sign a new CLA and secure permission from the new employer before submitting Contributions.

3. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "as is" basis, without warranties or conditions of any kind, either express or implied, including, without limitation, any warranties or conditions of title, non- infringement, merchantability, or fitness for a particular purpose.

## Notification to 4D

You agree to notify 4D in writing of any facts or circumstances of which You later become aware that would make Your representations in this CLA inaccurate in any respect.

## Laws and jurisdictions

This CLA is governed by the laws of France, and the Parties consent to exclusive jurisdiction and venue in the courts of Paris, France.
20 changes: 20 additions & 0 deletions .github/cla/signatures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"signedContributors": [
{
"name": "SBlaserBossinfo",
"id": 149789139,
"comment_id": 1801181011,
"created_at": "2023-11-08T06:35:52Z",
"repoId": 412014636,
"pullRequestNo": 36
},
{
"name": "SBlaserBossinfo",
"id": 149789139,
"comment_id": 1801234711,
"created_at": "2023-11-08T07:28:53Z",
"repoId": 412014636,
"pullRequestNo": 36
}
]
}
29 changes: 29 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]

# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
permissions:
actions: write
contents: write
pull-requests: write
statuses: write

jobs:
CLAAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: contributor-assistant/github-action@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path-to-signatures: '.github/cla/signatures.json'
path-to-document: 'https://github.com/4d/4D-NetKit/blob/main/.github/cla/4DCLA.md'
# branch should not be protected
branch: 'main'
allowlist: 4DBuildMgr,CGareau,DamienFuzeau,EricMinyem,Hafid4D,Ilhaba,JarosMachacek,Mohammed-Ouakani,RickiBarragan,Roland-Lannuzel,Souhail-Elmouhtadi,StephanieTrt,ThomasMaul,abdelkrim-bouhoute,addkomo4d,ahmed-rajouani-alaoui,amine-maqrot,anass-talii,arnaud4d,azzeddine-simmad,berengerelagrange,bfremont,brahim-boukobba,client-bugbase,crugeles,cyril-makloufi,david-azancot,delahaye-4D,djotandjigora,e-marchand,emmanuel-craeymeersch,fabrice-mainguene,franck-louvigne,francois-marchal,guillaume-kotulski,halima-laghroubi,hassan-ettanany,htemanni92,imjabber,intissarMez,isaac-gonzalezbottini,jacques-quidu,jean-laguerre,laurent-esnault,llaunay,lribardi,majda-elmaazouzi,mathieu-ferry,michel-blaise,mickael-cerisier,mickaelr4d,migad-negib,miyako,mouna-elmaazouzi,moussa-bellahcene,ms-landrieu,nhat-do1,nicolas-brachfogel,nobuteshima,noreddine-margoum,omar-hcine,omar-lakrari,omar-zaida,ossama-mourini,patrick-poly,pfhuillet,sclairet,shayanna-gatchalian,tai-bui1,vanessa-talbot,vdelachaux,vincent-laluque,walid-chekkouri,wtaylor-4d,yannicktrinh,zineb-aslioui
8 changes: 0 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ name: Lint

on:
push:
branches:
- "main"
- "2?R**"
- "2?.x"
paths:
- '**.xlf'
- '**.4DSettings'
- '**.4DCatalog'

pull_request:
branches:
- "main"
- "2?R**"
- "2?.x"
paths:
- '**.xlf'
- '**.4DSettings'
Expand Down
183 changes: 79 additions & 104 deletions Project/Sources/Classes/GoogleMail.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,77 +98,38 @@ Function _postMessage($inFunction : Text; $inURL : Text; $inMail : Variant; $inH
return $status


// Mark: - [Public]
// Mark: - Mails
// ----------------------------------------------------


Function _convertMailObjectToJMAP($inMail : Object) : Object
Function send($inMail : Variant) : Object

var $result : Object
var $keys : Collection
var $key; $name; $string : Text
var $email : cs.EmailAddress
var $URL; $userId : Text

$result:={}
$keys:=OB Keys($inMail)
For each ($key; $keys)
$name:=_getJMAPAttribute($key)
If (Length($name)>0)
If ($key="labelIds")
If (Num($inMail.labelIds.length)>0)
$string:=$inMail.labelIds.join("=true,"; ck ignore null or empty)+"=true"
$result[$name]:=Split string($string; ","; sk trim spaces)
End if
Else
$result[$name]:=$inMail[$key]
End if
End if
End for each

If (OB Is defined($inMail; "payload"))
$keys:=OB Keys($inMail.payload)
For each ($key; $keys)
If ($key="headers")
var $header : Object
For each ($header; $inMail.payload.headers)
$name:=_getJMAPAttribute($header.name)
If (Length($name)>0)
Case of
: ($header.name="Keywords")
If (Length($header.value)>0)
$string:=$header.value.join("=true,"; ck ignore null or empty)+"=true"
$result[$name]:=Split string($string; ","; sk trim spaces)
End if
: (_IsEmailAddressHeader($header.name))
If (Length($header.value)>0)
$email:=cs.EmailAddress.new($header.value)
$result[$name]:=OB Copy($email)
End if
Else
$result[$name]:=$header.value
End case
End if
End for each
End if
End for each
End if
$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$URL+="users/"+$userId+"/messages/send"

return $result
return This._postMessage("send"; $URL; $inMail)


// Mark: - [Public]
// Mark: - Mails
// ----------------------------------------------------


Function send($inMail : Variant) : Object
Function getLabelList() : Object

var $URL; $userId : Text
var $response : Object

Super._clearErrorStack()
$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$URL+="users/"+$userId+"/messages/send"
$URL+="users/"+$userId+"/labels"

return This._postMessage("send"; $URL; $inMail)
$response:=Super._sendRequestAndWaitResponse("GET"; $URL)

return This._returnStatus(OB Copy($response))


// ----------------------------------------------------
Expand Down Expand Up @@ -246,6 +207,7 @@ Function getMailIds($inParameters : Object) : Object

var $URL; $userId; $urlParams : Text

Super._clearErrorStack()
$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$urlParams+="users/"+$userId+"/messages"+This._getURLParamsFromObject($inParameters)
Expand All @@ -270,51 +232,21 @@ Function getMail($inMailId : Text; $inParameters : Object)->$response : Variant
Else

var $URL; $userId; $urlParams; $mailType; $format : Text
var $result : Object
var $result; $parameters : Object

$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$mailType:=(Length(String($inParameters.mailType))>0) ? $inParameters.mailType : This.mailType
$format:=String($inParameters.format)
$format:=(($format="minimal") || ($format="metadata")) ? $format : "raw"

$urlParams+="users/"+$userId+"/messages/"+String($inMailId)+This._getURLParamsFromObject($inParameters)
$parameters:=(($inParameters#Null) && (Value type($inParameters)=Is object)) ? $inParameters : {format: $format}
If ($parameters.format#$format)
$parameters.format:=$format
End if
$urlParams+="users/"+$userId+"/messages/"+String($inMailId)+This._getURLParamsFromObject($parameters)

$result:=Super._sendRequestAndWaitResponse("GET"; $URL+$urlParams)

If ($result#Null)

var $rawMessage : Text

Case of
: (($format="raw") && (($mailType="MIME") || ($mailType="JMAP")))
If (Value type($result.raw)=Is text)

$rawMessage:=_base64UrlSafeDecode($result.raw)
If ($mailType="JMAP")

var $copy : Object

$copy:=OB Copy($result)
$response:=MAIL Convert from MIME($rawMessage)
$response.id:=String($copy.id)
$response.threadId:=String($copy.threadId)
$response.labelIds:=OB Is defined($copy; "labelIds") ? $copy.labelIds : []
Else

$response:=(Length($rawMessage)>0) ? $rawMessage : $result.raw
End if
End if

: (($format="minimal") || ($format="metadata"))
$response:=This._convertMailObjectToJMAP($result)

Else
Super._throwError(10; {which: 1; function: "getMail"})

End case

End if
$response:=This._extractRawMessage($result; $format; $mailType)

End case

Expand All @@ -328,8 +260,8 @@ Function getMail($inMailId : Text; $inParameters : Object)->$response : Variant

Function getMails($inMailIds : Collection; $inParameters : Object) : Collection

Super._throwErrors(False)
Super._clearErrorStack()

Case of
: (Type($inMailIds)#Is collection)
Super._throwError(10; {which: "\"mailIds\""; function: "getMails"})
Expand All @@ -339,24 +271,63 @@ Function getMails($inMailIds : Collection; $inParameters : Object) : Collection

Else

var $result : Collection:=[]
var $response : Variant
var $result : Collection:=Null

If ($inMailIds.length=1)

$response:=This.getMail($inMailIds[0]; $inParameters)
$result.push($response)
var $response : Variant:=This.getMail($inMailIds[0]; $inParameters)
If ($response#Null)
$result:=New collection($response)
End if

Else

// TODO use cs._batchRequest Object
ASSERT(False; "Unimplemented")
var $URL; $urlParams; $userId; $mailType; $mailId; $format : Text
var $mailIds : Collection:=(Value type($inMailIds)=Is collection) ? $inMailIds : []
var $parameters : Object

If (($mailIds.length>0) && (Value type($mailIds[0])=Is object))
$mailIds:=$mailIds.extract("id")
End if

$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$mailType:=(Length(String($inParameters.mailType))>0) ? $inParameters.mailType : This.mailType
$format:=String($inParameters.format)
$format:=(($format="minimal") || ($format="metadata")) ? $format : "raw"
$parameters:=(($inParameters#Null) && (Value type($inParameters)=Is object)) ? $inParameters : {format: $format}
If ($parameters.format#$format)
$parameters.format:=$format
End if

var $i : Integer:=1
var $batchRequestes : Collection:=[]

For each ($mailId; $mailIds)
var $item : Text:="<item"+String($i)+">"
$i+=1
$urlParams:="users/"+$userId+"/messages/"+$mailId+This._getURLParamsFromObject($parameters)
$batchRequestes.push({request: {verb: "GET"; URL: $URL+$urlParams; id: $item}})
End for each

var $batchParams : Object:={batchRequestes: $batchRequestes; mailType: $mailType; format: $format}
var $batchRequest : cs._GoogleBatchRequest:=cs._GoogleBatchRequest.new(This._getOAuth2Provider(); $batchParams)
$result:=$batchRequest.sendRequestAndWaitResponse()

If (($result=Null) || ($batchRequest._getLastError()#Null))
var $stack : Collection:=$batchRequest._getErrorStack().reverse()
var $error : Object

For each ($error; $stack)
This._getErrorStack().push($error)
throw($error)
End for each
End if

End if

End case

Super._throwErrors(True)

return $result


Expand Down Expand Up @@ -386,15 +357,19 @@ Function update($inMailIds : Collection; $inParameters : Object) : Object
var $response : Object
var $headers : Object:={}
var $body : Object:={}
var $mailIds : Collection:=(Type($inMailIds[0])=Is object) ? $inMailIds.extract("id") : $inMailIds
var $mailIds : Collection:=(Value type($inMailIds)=Is collection) ? $inMailIds : []

If (($mailIds.length>0) && (Value type($mailIds[0])=Is object))
$mailIds:=$mailIds.extract("id")
End if

$URL:=Super._getURL()
$userId:=(Length(String(This.userId))>0) ? This.userId : "me"
$URL+="users/"+$userId+"/messages/batchModify"

$body.ids:=$mailIds
$body.addLabelIds:=(Type($inParameters.addLabelIds)=Is collection) ? $inParameters.addLabelIds : []
$body.removeLabelIds:=(Type($inParameters.removeLabelIds)=Is collection) ? $inParameters.removeLabelIds : []
$body.addLabelIds:=(Value type($inParameters.addLabelIds)=Is collection) ? $inParameters.addLabelIds : []
$body.removeLabelIds:=(Value type($inParameters.removeLabelIds)=Is collection) ? $inParameters.removeLabelIds : []

$response:=Super._sendRequestAndWaitResponse("POST"; $URL; $headers; $body)
This._internals._response:=OB Copy($response)
Expand Down
Loading

0 comments on commit 9ccad37

Please sign in to comment.