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

Add flag on mqtt history endpoint #20

Merged
merged 11 commits into from
Apr 13, 2022
Merged

Conversation

mflilian
Copy link
Contributor

@mflilian mflilian commented Apr 12, 2022

Motivation

Given the needed of retrieving blocked messages from MQTT History: on this MR we are we adding a flag on its endpoint to introduce a better experience for those who will receive these messages.

How to test it

Pre-requisites

  1. Start the database and populate MongoDB with make deps setup/mongo;
  2. Connect into mongoDB and run the following command:
> use chat

> db.messages.insertMany([
  {
    _id: ObjectId("61f18d6e901b304d707fd803"),
    id: 'urn:uuid:fe67bc4a-6517-4c96-a89d-09b7fe6e1e8e',
    player_id: 1,
    game_id: 'mygame',
    topic: 'chat/mygame/room/general',
    message: 'Hello World',
    timestamp: 1643220334,
    blocked: false,
    metadata: {
      blocked: false,
      Type: 1,
      Time: NumberLong("637788171338607270"),
      Sender: { PlayerId: 1, Name: 'Bob' },
      Message: 'Hello World',
      Mentions: [],
      Id: 'urn:uuid:fe67bc4a-6517-4c96-a89d-09b7fe6e1e8e',
      GameId: 'mygame'
    },
    should_moderate: true,
    original_payload: {
      blocked: false,
      Type: 1,
      Time: NumberLong("637788171338607270"),
      Sender: { PlayerId: 1, Name: 'Bob' },
      Message: 'Hello World',
      Mentions: [],
      Id: 'urn:uuid:fe67bc4a-6517-4c96-a89d-09b7fe6e1e8e',
      GameId: 'mygame'
    }
  },
  {
    _id: ObjectId("61f0f98027b114a532751e05"),
    id: 'urn:uuid:cf7711d6-95df-4be7-8b9a-6ecfb812c408',
    player_id: 'alice',
    game_id: 'myanothergame',
    topic: 'chat/myanothergame/room/general',
    message: 'Hi',
    timestamp: 1643182464,
    blocked: true,
    metadata: {
      blocked: true,
      Type: 1,
      Time: NumberLong("637787792628932950"),
      Sender: { PlayerId: 'alice', Name: 'Alice' },
      Message: 'Hi',
      Mentions: [],
      Id: 'urn:uuid:cf7711d6-95df-4be7-8b9a-6ecfb812c408',
      GameId: 'myanothergame'
    },
    should_moderate: true,
    original_payload: {
      blocked: true,
      Type: 1,
      Time: NumberLong("637787792628932950"),
      Sender: { PlayerId: 'alice', Name: 'Alice' },
      Message: 'Hi',
      Mentions: [],
      Id: 'urn:uuid:cf7711d6-95df-4be7-8b9a-6ecfb812c408',
      GameId: 'myanothergame'
    }
  }
])
  1. Start the API with make run.

Test cases

Retrieving messages from games that have isBlocked:false

  • Given I am an API consumer
  • When I try to query my game messages
curl --location --request GET 'http://localhost:8888/history/chat/mygame/room/general?userid=mygame:metagame-mygame&limit=1000&isBlocked=false'
  • Then I should return JSON array with my messages
# you should see an array with one message from Bob

Retrieving messages from games that have isBlocked:true

  • Given I am an API consumer
  • When I try to query my game messages
curl --location --request GET 'http://localhost:8888/history/chat/myanothergame/room/general?userid=myanothergame:metagame-myanothergame&limit=1000'
  • Then I should return JSON array with my messages
# you should see an array with one message from Alice

--
*PS Although we have included isBlocked=falsein our endpoint, this value is already configured as default.

@coveralls
Copy link

coveralls commented Apr 12, 2022

Coverage Status

Coverage increased (+0.2%) to 75.244% when pulling 3d34a54 on add-flag-on-mqtt-history-endpoint into cef412b on master.

app/query_param.go Outdated Show resolved Hide resolved
app/query_param.go Outdated Show resolved Hide resolved
app/history_v2_test.go Show resolved Hide resolved
app/query_param.go Outdated Show resolved Hide resolved
app/query_param.go Outdated Show resolved Hide resolved
app/query_param.go Outdated Show resolved Hide resolved
@mflilian mflilian merged commit 5456a5b into master Apr 13, 2022
@mflilian mflilian self-assigned this Nov 11, 2022
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.

None yet

4 participants