@@ -209,14 +209,32 @@ func (b *Backend) RemoveUserKey(userID, keyID string) error {
209209}
210210
211211func (b * Backend ) CreateAddress (userID , email string , password []byte , withKey bool , status proton.AddressStatus , addrType proton.AddressType ) (string , error ) {
212- return b .createAddress (userID , email , password , withKey , status , addrType , false )
212+ return b .createAddress (userID , email , password , withKey , status , addrType , false , true )
213213}
214214
215215func (b * Backend ) CreateAddressAsUpdate (userID , email string , password []byte , withKey bool , status proton.AddressStatus , addrType proton.AddressType ) (string , error ) {
216- return b .createAddress (userID , email , password , withKey , status , addrType , true )
216+ return b .createAddress (userID , email , password , withKey , status , addrType , true , true )
217217}
218218
219- func (b * Backend ) createAddress (userID , email string , password []byte , withKey bool , status proton.AddressStatus , addrType proton.AddressType , issueUpdateInsteadOfCreate bool ) (string , error ) {
219+ func (b * Backend ) CreateAddressWithSendDisabled (
220+ userID , email string ,
221+ password []byte ,
222+ withKey bool ,
223+ status proton.AddressStatus ,
224+ addrType proton.AddressType ,
225+ ) (string , error ) {
226+ return b .createAddress (userID , email , password , withKey , status , addrType , false , false )
227+ }
228+
229+ func (b * Backend ) createAddress (
230+ userID , email string ,
231+ password []byte ,
232+ withKey bool ,
233+ status proton.AddressStatus ,
234+ addrType proton.AddressType ,
235+ issueUpdateInsteadOfCreate bool ,
236+ allowSend bool ,
237+ ) (string , error ) {
220238 return withAcc (b , userID , func (acc * account ) (string , error ) {
221239 var keys []key
222240
@@ -257,12 +275,13 @@ func (b *Backend) createAddress(userID, email string, password []byte, withKey b
257275 addressID := uuid .NewString ()
258276
259277 acc .addresses [addressID ] = & address {
260- addrID : addressID ,
261- email : email ,
262- order : len (acc .addresses ) + 1 ,
263- status : status ,
264- addrType : addrType ,
265- keys : keys ,
278+ addrID : addressID ,
279+ email : email ,
280+ order : len (acc .addresses ) + 1 ,
281+ status : status ,
282+ addrType : addrType ,
283+ keys : keys ,
284+ allowSend : allowSend ,
266285 }
267286
268287 var update update
@@ -295,6 +314,18 @@ func (b *Backend) ChangeAddressType(userID, addrId string, addrType proton.Addre
295314 })
296315}
297316
317+ func (b * Backend ) ChangeAddressAllowSend (userID , addrId string , allowSend bool ) error {
318+ return b .withAcc (userID , func (acc * account ) error {
319+ for _ , addr := range acc .addresses {
320+ if addr .addrID == addrId {
321+ addr .allowSend = allowSend
322+ return nil
323+ }
324+ }
325+ return fmt .Errorf ("no addrID matching %s for user %s" , addrId , userID )
326+ })
327+ }
328+
298329func (b * Backend ) CreateAddressKey (userID , addrID string , password []byte ) error {
299330 return b .withAcc (userID , func (acc * account ) error {
300331 token , err := crypto .RandomToken (32 )
0 commit comments