Skip to content

Instantly share code, notes, and snippets.

@gregblake
gregblake / browse-rooms-test-scenarios.md
Created April 5, 2022 19:12
Browse Rooms Test Scenarios

Browse Rooms Cypress Test Scenarios

What we want to validate on this page (the first two are the most important):

  1. Can the current user see every room that should be visible to them?
  2. Can the current user see any rooms that should not be visible to them?
  3. Are other elements accurate? For example, the room roster count, the room names, and the public/private icon.

To answer those questions, here's how we should set these tests up:

@gregblake
gregblake / message_query.rb
Created December 6, 2021 13:32
Error Catching
def new_query(params, current_user)
begin
# existing code from `new_query`
rescue ActiveRecord::StatementInvalid => e
binding.pry
end
end
@gregblake
gregblake / directMessage.js
Last active November 11, 2021 14:12
Creating a Direct Message Using the Matrix JS SDK
const createRoom = (userIdForNewDM) => {
enum Preset {
PrivateChat = "private_chat",
TrustedPrivateChat = "trusted_private_chat",
PublicChat = "public_chat",
}
enum Visibility {
Public = "public",
Private = "private",
}
@gregblake
gregblake / edge_cases.md
Last active October 14, 2021 18:25
Circulate: Edge Cases to Handle for Issue #672

Edge cases:

With and without holds:

  • No filter, no category ✅
  • "available" filter, no category, with and without a hold ✅
  • No filter, with category: should show items with loan or a hold. ✅
  • "available" filter, with category ✅

With and without loans, when it's an item with a borrow policy:

@gregblake
gregblake / gist:bfbce67d7c14efd150ad64b7ea944893
Created March 4, 2021 20:07
Error when running jest on ContentRow.spec.js: XMLHttpRequest is not defined
$ jest /Users/greg/code/connect-rn/__tests__/components/Events/ContentRow.spec.js
FAIL __tests__/components/Events/ContentRow.spec.js
● Test suite failed to run
ReferenceError: XMLHttpRequest is not defined
56 | }
57 |
> 58 | let hasonprogress = new XMLHttpRequest().onprogress === null
| ^
@gregblake
gregblake / notification_preview_enabled.md
Last active February 25, 2021 12:46
422 When Making a request to set the notification previews preference
  • The server responds with a 422 because the notification_preview_enabled value is required, but it is undefined on this request.
  • To resolve this bug, the client should set the notification_preview_enabled value to true by default, and the value should change when it makes another request whenever the user changes the toggle on the app.
[Thu Feb 25 2021 07:12:21.876]  LOG      AXIOS Request:  {"adapter": [Function xhrAdapter], "data": {"connect_client_preference": {"app_uuid": "3ac5d1e6a71680fe", "device_type": "Google/Android SDK built for x86", "notification_preview_enabled": undefined}}, "headers": {"Accept": "application/json", "User-Agent": "Connect {\"app_id\":\"com.powerhrg.connect.dev\",\"build_number\":1,\"os_version\":27,\"device\":\"unknown\",\"os\":\"Android\"}", "common": {"Accept": "
@gregblake
gregblake / apns_p8.md
Created December 28, 2020 15:03
Migrating from APNS2 Certificates to APNS P8 Token Based Authentication

Migrating from APNS2 Certificates to APNS P8 Token Based Authentication:

  • The existing rpush certs are set to expire on January 3rd, 2021. These certs, which can be used with APNS v1 and v2, need to be renewed every 13 months. In the past, the renewal process has been time consuming and tedious (it often involves several team members, and importing data into production).
  • With the changes on this PR, Rpush uses APNS P8 Token Based Authentication, instead of the annually renewable certificate we used on APNS v1 and v2.
  • The main benefit of using P8 token based authentication is that they don't expire, so we'll never have to renew these certs with Apple (which is similar to how the GCM certs work with Google). This link contains a breakdown of the other benefits of using P8, compared to certificates.
  • In addition, this PR uses data stored i
@gregblake
gregblake / unread.rb
Created September 17, 2020 14:38
Unread key on the state endpoint
[3] pry(main)> Connect::Notification.summary_for(effective_user)
=> {:reactions=>0,
:users=>{2=>19, 618=>17},
:rooms=>
{138=>{:messages=>10, :mentions=>0, :mentions_direct=>0, :mentions_all=>0},
1976=>{:messages=>1, :mentions=>1, :mentions_direct=>1, :mentions_all=>0},
10278=>{:messages=>3, :mentions=>3, :mentions_direct=>2, :mentions_all=>1},
10783=>{:messages=>23, :mentions=>0, :mentions_direct=>0, :mentions_all=>0},
19319=>{:messages=>148, :mentions=>5, :mentions_direct=>0, :mentions_all=>5},
23514=>{:messages=>130, :mentions=>13, :mentions_direct=>0, :mentions_all=>13},
@gregblake
gregblake / testing_connect_notifications.md
Last active August 7, 2023 14:40
How to Test Connect Notifications

How to Test Connect Notifications

Overview

Connect has 3 types of conversations: 1-on-1's, Rooms, and Group Conversations. The rules for are different for displaying notifications for each conversation type.

Connect mobile clients have an APP-level preference that enables/disables message previews on the lock screen. This preference is enabled by default (which means that the contents of the message will be visible on the notification itself). But this can be disabled, and the notification displays placeholder text (like "Greg mentioned you in Rebel Alliance").

Conversation Types

1-on-1 and Group Conversations are straight forward. The notifications should always be displayed to the user, and the "is Connecting with you" style text always remains the same for each conversation type.

Note: if notification previews are enabled, then the notification should display the contents of the message.

@gregblake
gregblake / payload.rb
Created August 27, 2020 13:16
New room_info key on the mobile notification payload
{:data=>
{:aps=>{:"content-available"=>true, :sound=>""},
:"message-type"=>"connect",
:"as-of"=>"2020-08-27T09:15:17-04:00",
:"nitro-environment"=>"development",
:user_id=>33868,
:connect_message_id=>59955711,
:message_prefetch=>true,
:connect_message=>
{:messages=>