Page MenuHomePhabricator

[native] introduce new updateRolesAndPermissions migration util
AcceptedPublic

Authored by ginsu on Wed, May 15, 6:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 24, 4:16 AM
Unknown Object (File)
Thu, May 23, 6:16 PM
Unknown Object (File)
Thu, May 23, 8:37 AM
Unknown Object (File)
Thu, May 23, 1:37 AM
Unknown Object (File)
Wed, May 22, 4:07 PM
Unknown Object (File)
Tue, May 21, 1:18 PM
Unknown Object (File)
Tue, May 21, 3:08 AM
Unknown Object (File)
Mon, May 20, 4:33 AM
Subscribers

Details

Reviewers
ashoat
Summary

The last step for introducing the communities table in the keyserver + tagging farcaster channel project is we need to introduce a new permission to manage the farcaster channel tags. Part of this task will be to perform a redux migrations so that native clients add this permission manage farcaster tag permission. However, as part of the work to minimally encode the permissions, updateRolesAndPermissions became legacyUpdateRolesAndPermissions since it was dealing with the LegacyRawThreadInfo. Discussed this with @ashoat and we came up with a plan for the new updateRolesAndPermissions method:

  1. Call decodeMinimallyEncodedRawThreadInfo to decode all thread infos into LegacyRawThreadInfo
  2. Call legacyUpdateRolesAndPermissions to perform the migration
  3. Call minimallyEncodeRawThreadInfo to re-encode the threadinfos from LegacyRawThreadInfo into a RawThreadInfo

Depends on D12060

Test Plan

Ran the migration in the very next diff and logged out threadStoreInfos at the very beginning of the method and then logged out updatedThreadStoreInfos at the very end of the method. Put both logs into a json compare tool and the diff between the two json objects looked reasonable.

threadStoreInfos:

{
	"256|1": {
		"minimallyEncoded": true,
		"id": "256|1",
		"type": 12,
		"name": "GENESIS",
		"description": "This is the first community on Comm. In the future it will be possible to create chats outside of a community, but for now all of these chats get set with GENESIS as their parent. GENESIS is hosted on Ashoat’s keyserver.",
		"color": "5c9f5f",
		"creationTime": 4797702872,
		"parentThreadID": null,
		"containingThreadID": null,
		"community": null,
		"members": [
			{
				"id": "256",
				"role": "256|83796",
				"permissions": "3f73ff",
				"isSender": false,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83795",
				"permissions": "3",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83795": {
				"id": "256|83795",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"005",
					"015",
					"0a7"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			},
			"256|83796": {
				"id": "256|83796",
				"name": "Admins",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"120",
					"080",
					"090",
					"0c0",
					"070",
					"0d0",
					"0e0",
					"130",
					"140",
					"150",
					"004",
					"014",
					"0a6",
					"0a8",
					"024",
					"034",
					"044",
					"064",
					"054",
					"124",
					"086",
					"096",
					"0c4",
					"074",
					"0b4",
					"0d4",
					"0e4",
					"134",
					"156"
				],
				"minimallyEncoded": true,
				"specialRole": 2
			}
		},
		"currentUser": {
			"role": "256|83795",
			"permissions": "3",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		},
		"repliesCount": 0,
		"pinnedCount": 0
	},
	"256|83815": {
		"minimallyEncoded": true,
		"id": "256|83815",
		"type": 6,
		"name": "",
		"description": "",
		"color": "5c9f5f",
		"creationTime": 4797702872,
		"parentThreadID": "256|1",
		"containingThreadID": "256|1",
		"community": "256|1",
		"members": [
			{
				"id": "256",
				"role": "256|83817",
				"permissions": "2f7fff",
				"isSender": true,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83817",
				"permissions": "3027f",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83817": {
				"id": "256|83817",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"090",
					"005",
					"015",
					"0a9"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			}
		},
		"currentUser": {
			"role": "256|83817",
			"permissions": "3027f",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		},
		"repliesCount": 0,
		"pinnedCount": 0
	},
	"256|83816": {
		"minimallyEncoded": true,
		"id": "256|83816",
		"type": 7,
		"name": "",
		"description": "This is your private chat, where you can set reminders and jot notes in private!",
		"color": "575757",
		"creationTime": 4797702872,
		"parentThreadID": "256|1",
		"containingThreadID": "256|1",
		"community": "256|1",
		"members": [
			{
				"id": "256",
				"role": null,
				"permissions": "2c7fff",
				"isSender": false,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83818",
				"permissions": "3026f",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83818": {
				"id": "256|83818",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"060",
					"050",
					"090",
					"030",
					"005",
					"015",
					"0a9"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			}
		},
		"currentUser": {
			"role": "256|83818",
			"permissions": "3026f",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		},
		"repliesCount": 0,
		"pinnedCount": 0
	},
	"256|83885": {
		"minimallyEncoded": true,
		"id": "256|83885",
		"type": 8,
		"name": "Run club",
		"description": "",
		"color": "575757",
		"creationTime": 4797702872,
		"parentThreadID": null,
		"containingThreadID": null,
		"community": null,
		"members": [
			{
				"id": "83810",
				"role": "256|83887",
				"permissions": "3ff3ff",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83886": {
				"id": "256|83886",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"005",
					"015",
					"0a7",
					"090",
					"0f0",
					"0a9",
					"020",
					"100",
					"110",
					"0c0",
					"0c9",
					"030",
					"040",
					"050",
					"060",
					"080",
					"120"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			},
			"256|83887": {
				"id": "256|83887",
				"name": "Admins",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"120",
					"080",
					"090",
					"0c0",
					"070",
					"0d0",
					"0e0",
					"130",
					"140",
					"150",
					"004",
					"014",
					"0a6",
					"0a8",
					"024",
					"034",
					"044",
					"064",
					"054",
					"124",
					"086",
					"096",
					"0c4",
					"074",
					"0b4",
					"0d4",
					"0e4",
					"134",
					"156",
					"0f0"
				],
				"minimallyEncoded": true,
				"specialRole": 2
			}
		},
		"currentUser": {
			"role": "256|83887",
			"permissions": "3ff3ff",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		},
		"repliesCount": 0,
		"pinnedCount": 0
	}
}

updatedThreadStoreInfos:

{
	"256|1": {
		"id": "256|1",
		"type": 12,
		"name": "GENESIS",
		"description": "This is the first community on Comm. In the future it will be possible to create chats outside of a community, but for now all of these chats get set with GENESIS as their parent. GENESIS is hosted on Ashoat’s keyserver.",
		"color": "5c9f5f",
		"creationTime": 4797702872,
		"parentThreadID": null,
		"containingThreadID": null,
		"community": null,
		"repliesCount": 0,
		"pinnedCount": 0,
		"minimallyEncoded": true,
		"members": [
			{
				"id": "256",
				"role": "256|83796",
				"permissions": "7f73ff",
				"isSender": false,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83795",
				"permissions": "3",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83795": {
				"id": "256|83795",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"005",
					"015",
					"0a7"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			},
			"256|83796": {
				"id": "256|83796",
				"name": "Admins",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"120",
					"080",
					"090",
					"0c0",
					"070",
					"0d0",
					"0e0",
					"130",
					"140",
					"150",
					"160",
					"004",
					"014",
					"0a6",
					"0a8",
					"024",
					"034",
					"044",
					"064",
					"054",
					"124",
					"086",
					"096",
					"0c4",
					"074",
					"0b4",
					"0d4",
					"0e4",
					"134",
					"156"
				],
				"minimallyEncoded": true,
				"specialRole": 2
			}
		},
		"currentUser": {
			"role": "256|83795",
			"permissions": "3",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		}
	},
	"256|83815": {
		"id": "256|83815",
		"type": 6,
		"name": "",
		"description": "",
		"color": "5c9f5f",
		"creationTime": 4797702872,
		"parentThreadID": "256|1",
		"containingThreadID": "256|1",
		"community": "256|1",
		"repliesCount": 0,
		"pinnedCount": 0,
		"minimallyEncoded": true,
		"members": [
			{
				"id": "256",
				"role": "256|83817",
				"permissions": "2f7fff",
				"isSender": true,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83817",
				"permissions": "3027f",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83817": {
				"id": "256|83817",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"090",
					"005",
					"015",
					"0a9"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			}
		},
		"currentUser": {
			"role": "256|83817",
			"permissions": "3027f",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		}
	},
	"256|83816": {
		"id": "256|83816",
		"type": 7,
		"name": "",
		"description": "This is your private chat, where you can set reminders and jot notes in private!",
		"color": "575757",
		"creationTime": 4797702872,
		"parentThreadID": "256|1",
		"containingThreadID": "256|1",
		"community": "256|1",
		"repliesCount": 0,
		"pinnedCount": 0,
		"minimallyEncoded": true,
		"members": [
			{
				"id": "256",
				"role": null,
				"permissions": "2c7fff",
				"isSender": false,
				"minimallyEncoded": true
			},
			{
				"id": "83810",
				"role": "256|83818",
				"permissions": "3026f",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83818": {
				"id": "256|83818",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"060",
					"050",
					"090",
					"030",
					"005",
					"015",
					"0a9"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			}
		},
		"currentUser": {
			"role": "256|83818",
			"permissions": "3026f",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		}
	},
	"256|83885": {
		"id": "256|83885",
		"type": 8,
		"name": "Run club",
		"description": "",
		"color": "575757",
		"creationTime": 4797702872,
		"parentThreadID": null,
		"containingThreadID": null,
		"community": null,
		"repliesCount": 0,
		"pinnedCount": 0,
		"minimallyEncoded": true,
		"members": [
			{
				"id": "83810",
				"role": "256|83887",
				"permissions": "7ff3ff",
				"isSender": false,
				"minimallyEncoded": true
			}
		],
		"roles": {
			"256|83886": {
				"id": "256|83886",
				"name": "Members",
				"permissions": [
					"000",
					"010",
					"005",
					"015",
					"0a7",
					"090",
					"0f0",
					"0a9",
					"020",
					"100",
					"110",
					"0c0",
					"0c9",
					"030",
					"040",
					"050",
					"060",
					"080",
					"120"
				],
				"minimallyEncoded": true,
				"specialRole": 1
			},
			"256|83887": {
				"id": "256|83887",
				"name": "Admins",
				"permissions": [
					"000",
					"010",
					"020",
					"100",
					"110",
					"030",
					"040",
					"060",
					"050",
					"120",
					"080",
					"090",
					"0c0",
					"070",
					"0d0",
					"0e0",
					"130",
					"140",
					"150",
					"160",
					"004",
					"014",
					"0a6",
					"0a8",
					"024",
					"034",
					"044",
					"064",
					"054",
					"124",
					"086",
					"096",
					"0c4",
					"074",
					"0b4",
					"0d4",
					"0e4",
					"134",
					"156",
					"0f0"
				],
				"minimallyEncoded": true,
				"specialRole": 2
			}
		},
		"currentUser": {
			"role": "256|83887",
			"permissions": "7ff3ff",
			"subscription": {
				"home": true,
				"pushNotifs": true
			},
			"unread": false,
			"minimallyEncoded": true
		}
	}
}

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu requested review of this revision.Wed, May 15, 7:06 PM
ginsu edited the test plan for this revision. (Show Details)
ginsu added a reviewer: ashoat.
ginsu edited the test plan for this revision. (Show Details)
native/redux/legacy-update-roles-and-permissions.js
57

This was causing flow errors when I called it in the new legacyUpdateRolesAndPermissions method. Confirmed that we just returning LegacyRawThreadInfos at the end of this method

Screenshot 2024-05-15 at 10.08.20 PM.png (428×1 px, 106 KB)

This revision is now accepted and ready to land.Thu, May 16, 10:08 AM