Skip to content

Commit 9cd7872

Browse files
AchoArnoldCopilot
andcommitted
feat(api): accept unarchive_thread in phone upsert request
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 239ce93 commit 9cd7872

5 files changed

Lines changed: 55 additions & 5 deletions

File tree

api/docs/docs.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,7 @@ const docTemplate = `{
33793379
},
33803380
"request_id": {
33813381
"type": "string",
3382-
"example": "bulk-csv-a1B2c3D4e5"
3382+
"example": "bulk-httpsms-file.csv"
33833383
},
33843384
"scheduled_count": {
33853385
"type": "integer",
@@ -3760,6 +3760,7 @@ const docTemplate = `{
37603760
"messages_per_minute",
37613761
"phone_number",
37623762
"sim",
3763+
"unarchive_thread",
37633764
"updated_at",
37643765
"user_id"
37653766
],
@@ -3804,6 +3805,11 @@ const docTemplate = `{
38043805
"sim": {
38053806
"$ref": "#/definitions/entities.SIM"
38063807
},
3808+
"unarchive_thread": {
3809+
"description": "UnarchiveThread moves an archived message thread back to the inbox when a new message is received on this phone.",
3810+
"type": "boolean",
3811+
"example": false
3812+
},
38073813
"updated_at": {
38083814
"type": "string",
38093815
"example": "2022-06-05T14:26:10.303278+03:00"
@@ -4436,7 +4442,8 @@ const docTemplate = `{
44364442
"messages_per_minute",
44374443
"missed_call_auto_reply",
44384444
"phone_number",
4439-
"sim"
4445+
"sim",
4446+
"unarchive_thread"
44404447
],
44414448
"properties": {
44424449
"fcm_token": {
@@ -4473,6 +4480,11 @@ const docTemplate = `{
44734480
"description": "SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot",
44744481
"type": "string",
44754482
"example": "SIM1"
4483+
},
4484+
"unarchive_thread": {
4485+
"description": "UnarchiveThread moves an archived thread back to the inbox when a new message is received on this phone.",
4486+
"type": "boolean",
4487+
"example": false
44764488
}
44774489
}
44784490
},

api/docs/swagger.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@
33763376
},
33773377
"request_id": {
33783378
"type": "string",
3379-
"example": "bulk-csv-a1B2c3D4e5"
3379+
"example": "bulk-httpsms-file.csv"
33803380
},
33813381
"scheduled_count": {
33823382
"type": "integer",
@@ -3757,6 +3757,7 @@
37573757
"messages_per_minute",
37583758
"phone_number",
37593759
"sim",
3760+
"unarchive_thread",
37603761
"updated_at",
37613762
"user_id"
37623763
],
@@ -3801,6 +3802,11 @@
38013802
"sim": {
38023803
"$ref": "#/definitions/entities.SIM"
38033804
},
3805+
"unarchive_thread": {
3806+
"description": "UnarchiveThread moves an archived message thread back to the inbox when a new message is received on this phone.",
3807+
"type": "boolean",
3808+
"example": false
3809+
},
38043810
"updated_at": {
38053811
"type": "string",
38063812
"example": "2022-06-05T14:26:10.303278+03:00"
@@ -4433,7 +4439,8 @@
44334439
"messages_per_minute",
44344440
"missed_call_auto_reply",
44354441
"phone_number",
4436-
"sim"
4442+
"sim",
4443+
"unarchive_thread"
44374444
],
44384445
"properties": {
44394446
"fcm_token": {
@@ -4470,6 +4477,11 @@
44704477
"description": "SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot",
44714478
"type": "string",
44724479
"example": "SIM1"
4480+
},
4481+
"unarchive_thread": {
4482+
"description": "UnarchiveThread moves an archived thread back to the inbox when a new message is received on this phone.",
4483+
"type": "boolean",
4484+
"example": false
44734485
}
44744486
}
44754487
},

api/docs/swagger.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ definitions:
5858
example: 30
5959
type: integer
6060
request_id:
61-
example: bulk-csv-a1B2c3D4e5
61+
example: bulk-httpsms-file.csv
6262
type: string
6363
scheduled_count:
6464
example: 50
@@ -388,6 +388,11 @@ definitions:
388388
type: string
389389
sim:
390390
$ref: '#/definitions/entities.SIM'
391+
unarchive_thread:
392+
description: UnarchiveThread moves an archived message thread back to the
393+
inbox when a new message is received on this phone.
394+
example: false
395+
type: boolean
391396
updated_at:
392397
example: "2022-06-05T14:26:10.303278+03:00"
393398
type: string
@@ -402,6 +407,7 @@ definitions:
402407
- messages_per_minute
403408
- phone_number
404409
- sim
410+
- unarchive_thread
405411
- updated_at
406412
- user_id
407413
type: object
@@ -908,6 +914,11 @@ definitions:
908914
1 SIM slot
909915
example: SIM1
910916
type: string
917+
unarchive_thread:
918+
description: UnarchiveThread moves an archived thread back to the inbox when
919+
a new message is received on this phone.
920+
example: false
921+
type: boolean
911922
required:
912923
- fcm_token
913924
- max_send_attempts
@@ -916,6 +927,7 @@ definitions:
916927
- missed_call_auto_reply
917928
- phone_number
918929
- sim
930+
- unarchive_thread
919931
type: object
920932
requests.UserNotificationUpdate:
921933
properties:

api/pkg/requests/phone_update_request.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type PhoneUpsert struct {
2929

3030
MissedCallAutoReply *string `json:"missed_call_auto_reply" example:"e.g. This phone cannot receive calls. Please send an SMS instead."`
3131

32+
// UnarchiveThread moves an archived thread back to the inbox when a new message is received on this phone.
33+
UnarchiveThread bool `json:"unarchive_thread" example:"false"`
34+
3235
// SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot
3336
SIM string `json:"sim" example:"SIM1"`
3437

@@ -75,6 +78,11 @@ func (input *PhoneUpsert) ToUpsertParams(user entities.AuthContext, source strin
7578
maxSendAttempts = &input.MaxSendAttempts
7679
}
7780

81+
var unarchiveThread *bool
82+
if _, exists := fields["unarchive_thread"]; exists {
83+
unarchiveThread = &input.UnarchiveThread
84+
}
85+
7886
var scheduleID *uuid.UUID
7987
if _, exists := fields["message_send_schedule_id"]; exists {
8088
if parsed, err := uuid.Parse(strings.TrimSpace(input.MessageSendScheduleID)); err == nil {
@@ -92,6 +100,7 @@ func (input *PhoneUpsert) ToUpsertParams(user entities.AuthContext, source strin
92100
FcmToken: fcmToken,
93101
UserID: user.ID,
94102
SIM: entities.SIM(input.SIM),
103+
UnarchiveThread: unarchiveThread,
95104
MessageSendScheduleID: scheduleID,
96105
}
97106
}

api/pkg/services/phone_service.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type PhoneUpsertParams struct {
104104
WebhookURL *string
105105
MessageExpirationDuration *time.Duration
106106
MissedCallAutoReply *string
107+
UnarchiveThread *bool
107108
SIM entities.SIM
108109
MessageSendScheduleID *uuid.UUID
109110
Source string
@@ -312,6 +313,10 @@ func (service *PhoneService) update(phone *entities.Phone, params *PhoneUpsertPa
312313
phone.MissedCallAutoReply = params.MissedCallAutoReply
313314
}
314315

316+
if params.UnarchiveThread != nil {
317+
phone.UnarchiveThread = *params.UnarchiveThread
318+
}
319+
315320
phone.SIM = params.SIM
316321
phone.MessageSendScheduleID = params.MessageSendScheduleID
317322

0 commit comments

Comments
 (0)