-
-
Notifications
You must be signed in to change notification settings - Fork 203
Added Expiration for Contact #143
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,12 @@ type CreateGroupResponse struct { | |
Id string `json:"id"` | ||
} | ||
|
||
type UpdateContactRequest struct { | ||
Name string `json:"name"` | ||
Number string `json:"number"` | ||
Expiration string `json:"expiration"` | ||
} | ||
|
||
type UpdateProfileRequest struct { | ||
Name string `json:"name"` | ||
Base64Avatar string `json:"base64_avatar"` | ||
|
@@ -338,14 +344,8 @@ func runSignalCli(wait bool, args []string, stdin string) (string, error) { | |
} | ||
} | ||
|
||
fullCmd := "" | ||
if(stdin != "") { | ||
fullCmd += "echo '" + stdin + "' | " | ||
} | ||
fullCmd += signalCliBinary + " " + strings.Join(args, " ") | ||
|
||
log.Debug("*) su signal-api") | ||
log.Debug("*) ", fullCmd) | ||
log.Debug("*) ", signalCliBinary, " ", strings.Join(args, " ")) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you accidentally removed some code here (probably due to a merging conflict), see: https://github.com/bbernhard/signal-cli-rest-api/blob/master/src/api/api.go#L345 |
||
cmd := exec.Command(signalCliBinary, args...) | ||
if stdin != "" { | ||
|
@@ -470,6 +470,48 @@ func (a *Api) RegisterNumber(c *gin.Context) { | |
c.Writer.WriteHeader(201) | ||
} | ||
|
||
// @Summary Update contact. | ||
// @Tags Contact | ||
// @Description Update message expiration time for a user. | ||
// @Accept json | ||
// @Produce json | ||
// @Success 201 {string} string "OK" | ||
// @Failure 400 {object} Error | ||
// @Param data body UpdateContactRequest true "Input Data" | ||
// @Router /v1/updatecontact [post] | ||
func (a *Api) UpdateContact(c *gin.Context) { | ||
var req UpdateContactRequest | ||
err := c.BindJSON(&req) | ||
if err != nil { | ||
c.JSON(400, gin.H{"error": "Couldn't process request - invalid request"}) | ||
log.Error(err.Error()) | ||
return | ||
} | ||
|
||
if len(req.Number) == 0 { | ||
c.JSON(400, gin.H{"error": "Couldn't process request - please provide the recipients number"}) | ||
return | ||
} | ||
|
||
if len(req.Name) == 0 { | ||
c.JSON(400, gin.H{"error": "Couldn't process request - please provide the recipients name number"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a |
||
} | ||
|
||
if len(req.Expiration) == 0 { | ||
c.JSON(400, gin.H{"error": "Couldn't process request - please provide an expirty time in seconds"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a |
||
} | ||
|
||
command := []string{"--config", a.signalCliConfig, "updateContact", req.Number, "-n", req.Name, "-e", req.Expiration} | ||
|
||
_, err = runSignalCli(false, command, "") | ||
if err != nil { | ||
c.JSON(400, Error{Msg: err.Error()}) | ||
return | ||
} | ||
c.Writer.WriteHeader(201) | ||
} | ||
|
||
|
||
// @Summary Verify a registered phone number. | ||
// @Tags Devices | ||
// @Description Verify a registered phone number with the signal network. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,11 @@ func main() { | |
identities.GET(":number", api.ListIdentities) | ||
identities.PUT(":number/trust/:numbertotrust", api.TrustIdentity) | ||
} | ||
|
||
contacts := v1.Group("updatecontact") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I would prefer if we could change the endpoint to |
||
{ | ||
contacts.POST("", api.UpdateContact) | ||
} | ||
} | ||
|
||
v2 := router.Group("/v2") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to change the type to
int
here. Maybe also make it more clear that it's a time?so e.g something like:
ExpirationTime int
json:"expiration_time"``?