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

Ft adding message field optional #132

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

alpeshvas
Copy link

@alpeshvas alpeshvas commented Jan 17, 2022

Sneak peak:
demo

package.json Outdated Show resolved Hide resolved
@connorads
Copy link
Owner

connorads commented Jan 19, 2022

Good to speak with you the other day @alpeshvas
Thanks again for your PR 🚀

I've thought of a few places that will need updating with this change:

I'm hoping to take a proper look at this PR sometime this week 🤞

@alpeshvas
Copy link
Author

Good to speak with you the other day @alpeshvas Thanks again for your PR rocket

I've thought of a few places that will need updating with this change:

I'm hoping to take a proper look at this PR sometime this week crossed_fingers

Will make those changes.

@alpeshvas
Copy link
Author

Good to speak with you the other day @alpeshvas Thanks again for your PR rocket
I've thought of a few places that will need updating with this change:

I'm hoping to take a proper look at this PR sometime this week crossed_fingers

Will make those changes.

Done. Also, we can use something like this for auto generation of swagger , wdyt @connorads ?https://www.serverless.com/plugins/serverless-openapi-documentation

@connorads
Copy link
Owner

Nice one @alpeshvas!

Unfortunately we got some lint and type check errors in CI
image

Try running yarn lint locally

  • The lint issues should be easily fixed by running yarn eslint --fix "**/*.{js,ts}" and committing the changes
  • The type issue can be fixed by using adding a type annotation respondArguments: RespondArguments
    image
    image

If you want to see what is being run on CI you can have a look at the build script
https://github.com/connorads/lockbot/blob/master/.github/workflows/build.yml#L19

@connorads
Copy link
Owner

Done. Also, we can use something like this for auto generation of swagger , wdyt @connorads ?https://www.serverless.com/plugins/serverless-openapi-documentation

Nice idea. I'm open to autogeneration ideas but if I understand correctly this plugin doesn't appear to offer much automation.
It just seems to move the spec into serverless.yml. I'd rather keep the spec separate and in a standard format if we're not getting much added value.

image

@alpeshvas alpeshvas force-pushed the ft-adding-message-field-optional branch from 15e2f9e to 6b6c683 Compare February 6, 2022 13:14
@alpeshvas alpeshvas force-pushed the ft-adding-message-field-optional branch from 6b6c683 to a66b229 Compare February 6, 2022 13:22
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 99.408% when pulling bd83d93 on alpeshvas:ft-adding-message-field-optional into ca5225b on connorads:master.

name: nonEmptyWhitespaceFreeString,
owner: nonEmptyWhitespaceFreeString,
}),
// Making message field optional for backward compatibility
Copy link
Owner

@connorads connorads Feb 13, 2022

Choose a reason for hiding this comment

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

We can remove this comment
It's not just for backwards compatibility, people also might not chose to add a description - so it's always optional

getFirstParam(command.text),
handleCommand((command) => {
const resourceName = getFirstParam(command.text);
const descriptionMessage = getSecondParam(command.text);
Copy link
Owner

Choose a reason for hiding this comment

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

I was thinking instead of message or descriptionMessage we could consistently call this description everywhere in the types/code/spec/docs etc.

@@ -25,6 +25,7 @@ export type Destination = "user" | "channel";
export interface Response {
message: string;
destination: Destination;
metaData?: Record<string, string>;
Copy link
Owner

@connorads connorads Feb 13, 2022

Choose a reason for hiding this comment

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

This metaData was never meant to be read out of the DynamoDB via code.

I don't want us to read the metaData out of the DB ever and maybe we should just pass an optional description?: string back in the Response.

That wasn't for you to know, it's not obvious, I thought you added it at first 😅
The metaData is just to be able to store human-readable data in the database for the rare occasion I need to look in DynamoDB via AWS Console and see how people are using it - to understand current use-cases. Otherwise it's a lot of unreadable team/channel/user slack codes.

#69
image

@@ -25,6 +25,7 @@ export type Destination = "user" | "channel";
export interface Response {
Copy link
Owner

Choose a reason for hiding this comment

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

If you scroll up a bit you can see the LockRepo interface.

I think we'll have to return an additional description?: string from getAll so that the description can be seen in /locks. There will also need to be some additional tests and implementation etc. such has displaying locks with and without a description.

Then for setOwner I think it would make sense to pass description?: string after team and before metadata

Screen Shot 2022-02-13 at 8 39 28 PM

},
});
});

Copy link
Owner

@connorads connorads Feb 13, 2022

Choose a reason for hiding this comment

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

If you try to get the description after storing it will not work because there's no code to retrieve it.
It only shows the description when you lock it but not when you type /locks or try and get the description from the API.

If you try this test it will fail

  test("Create lock with description, get lock", async () => {
    await server
      .post("/dev/api/teams/T012345WXYZ/channels/C012345ABCD/locks")
      .set("Authorization", `Basic ${credentials1}`)
      .send('{ "name": "dev", "owner": "U012345MNOP", "message": "Hey man" }');

    const res = await server
      .get("/dev/api/teams/T012345WXYZ/channels/C012345ABCD/locks/dev")
      .set("Authorization", `Basic ${credentials1}`);

    expect(res.status).toBe(200);
    expect(res.text).toBe(
      JSON.stringify({
        name: "dev",
        owner: "U012345MNOP",
        message: "Hey man",
      })
    );
  });

image

text: message,
response_type: getResponseType(destination),
};
if (metaData && metaData.Message) {
respondArguments.attachments = [
Copy link
Owner

@connorads connorads Feb 13, 2022

Choose a reason for hiding this comment

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

I don't think attachments is the right thing here.

I think we could use Block quote instead and just incoporate it into the message. Although I'm not sure how we'd also make the description look nice when using /locks, perhaps a newline and italics? Would have to have a think/experiment.

In slack attachments looks very similar to a Block quote
image
which is what we use with /locks
image

Except you can remove the attachment, which is probably undesirable
image
image

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.

Allow optional message when locking
3 participants