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

Removed skipInviteAccept and JOINING_GROUP_CHAT #1767

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/0.2.0/group-slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -8682,7 +8682,7 @@ ${this.getErrorInfo()}`;
const rootState = (0, import_sbp6.default)("state/vuex/state");
const username = data.username || meta.username;
if (username === rootState.loggedIn.username) {
if (!(0, import_sbp6.default)("okTurtles.data/get", "JOINING_GROUP-" + contractID) || (0, import_sbp6.default)("okTurtles.data/get", "JOINING_GROUP_CHAT")) {
if (!(0, import_sbp6.default)("okTurtles.data/get", "JOINING_GROUP-" + contractID)) {
await (0, import_sbp6.default)("chelonia/contract/sync", data.chatRoomID);
(0, import_sbp6.default)("okTurtles.data/set", "JOINING_GROUP_CHAT", false);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.2.0/group.0.2.0.manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"head":{"manifestVersion":"1.0.0"},"body":"{\"version\":\"0.2.0\",\"contract\":{\"hash\":\"21XWnNL4g66rNK5wkSH9vZD6H6ZDJXJ84ecvCzPkBoaiCHkgmM\",\"file\":\"group.js\"},\"authors\":[{\"cipher\":\"algo\",\"key\":\"<pubkey from deploy-key.json>\"},{\"cipher\":\"algo\",\"key\":\"<pubkey from alex.json>\"}],\"contractSlim\":{\"file\":\"group-slim.js\",\"hash\":\"21XWnNMhWKeNnBG1upPDBdvrKWuERWGaKdNpCUcyfQ7Bj6QG3y\"}}","signature":{"key":"<which of the 'authors' keys was used to sign 'body'>","signature":"<signature>"}}
{"head":{"manifestVersion":"1.0.0"},"body":"{\"version\":\"0.2.0\",\"contract\":{\"hash\":\"21XWnNTDBVo8sdhmsLfEUgDqeeYszAA2zxvrUJVrYvAkQm8rDN\",\"file\":\"group.js\"},\"authors\":[{\"cipher\":\"algo\",\"key\":\"<pubkey from deploy-key.json>\"},{\"cipher\":\"algo\",\"key\":\"<pubkey from alex.json>\"}],\"contractSlim\":{\"file\":\"group-slim.js\",\"hash\":\"21XWnNTJzgPD8iTzth3qUcytcLge5zUoPoJbAEX7Ey8YcgzPsU\"}}","signature":{"key":"<which of the 'authors' keys was used to sign 'body'>","signature":"<signature>"}}
2 changes: 1 addition & 1 deletion contracts/0.2.0/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -17803,7 +17803,7 @@ ${this.getErrorInfo()}`;
const rootState = (0, import_sbp7.default)("state/vuex/state");
const username = data.username || meta.username;
if (username === rootState.loggedIn.username) {
if (!(0, import_sbp7.default)("okTurtles.data/get", "JOINING_GROUP-" + contractID) || (0, import_sbp7.default)("okTurtles.data/get", "JOINING_GROUP_CHAT")) {
if (!(0, import_sbp7.default)("okTurtles.data/get", "JOINING_GROUP-" + contractID)) {
await (0, import_sbp7.default)("chelonia/contract/sync", data.chatRoomID);
(0, import_sbp7.default)("okTurtles.data/set", "JOINING_GROUP_CHAT", false);
}
Expand Down
28 changes: 14 additions & 14 deletions frontend/controller/actions/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,27 @@ export default (sbp('sbp/selectors/register', {
// secret keys to be shared with us, (b) ready to call the inviteAccept
// action if we haven't done so yet (because we were previously waiting for
// the keys), or (c) already a member and ready to interact with the group.
'gi.actions/group/join': async function (params: $Exact<ChelKeyRequestParams> & { options?: { skipUsableKeysCheck?: boolean; skipInviteAccept?: boolean } }) {
'gi.actions/group/join': async function (params: $Exact<ChelKeyRequestParams> & { options?: { skipUsableKeysCheck?: boolean } }) {
sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, true)
try {
const rootState = sbp('state/vuex/state')
const username = rootState.loggedIn.username
const userID = rootState.loggedIn.identityContractID

console.log('@@@@@@@@ AT join for ' + params.contractID)
// params.originatingContractID is set, it means that we're joining through an invite link,
const isJoiningGroup = !!params.originatingContractID
const preEffectBeforeSync = isJoiningGroup
? () => { sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, true) }
: () => {}
const postEffectAfterSync = isJoiningGroup
? () => { sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, false) }
: () => {}

console.log('@@@@@@@@ AT join for ' + params.contractID)
preEffectBeforeSync()
await sbp('chelonia/contract/sync', params.contractID)
postEffectAfterSync()

if (rootState.contracts[params.contractID]?.type !== 'gi.contracts/group') {
throw Error(`Contract ${params.contractID} is not a group`)
}
Expand Down Expand Up @@ -527,7 +538,7 @@ export default (sbp('sbp/selectors/register', {
saveLoginState('joining', params.contractID)
}
},
'gi.actions/group/joinAndSwitch': async function (params: $Exact<ChelKeyRequestParams> & { options?: { skipUsableKeysCheck?: boolean; skipInviteAccept: boolean } }) {
'gi.actions/group/joinAndSwitch': async function (params: $Exact<ChelKeyRequestParams> & { options?: { skipUsableKeysCheck?: boolean } }) {
await sbp('gi.actions/group/join', params)
// after joining, we can set the current group
sbp('gi.actions/group/switch', params.contractID)
Expand Down Expand Up @@ -676,17 +687,6 @@ export default (sbp('sbp/selectors/register', {
}
})

if (username === me) {
// 'JOINING_GROUP_CHAT' is necessary to identify the joining chatroom action is NEW or OLD
// Users join the chatroom thru group making group actions
// But when user joins the group, he needs to ignore all the actions about chatroom
// Because the user is joining group, not joining chatroom
// and he is going to make a new action to join 'General' chatroom AGAIN
// While joining group, we don't set this flag because Joining chatroom actions are all OLD ones, which need to be ignored
// Joining 'General' chatroom is one of the steps to join group
// So setting 'JOINING_GROUP_CHAT' can not be out of the 'JOINING_GROUP' scope
sbp('okTurtles.data/set', 'JOINING_GROUP_CHAT', true)
}
await sendMessage({
...omit(params, ['options', 'action', 'hooks']),
hooks: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/controller/actions/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export default (sbp('sbp/selectors/register', {
console.info('synchronizing login state:', { groupsJoined })
for (const contractID of groupsJoined) {
try {
await sbp('gi.actions/group/join', { contractID, options: { skipInviteAccept: true } })
await sbp('gi.actions/group/join', { contractID })
} catch (e) {
console.error(`updateLoginStateUponLogin: ${e.name} attempting to join group ${contractID}`, e)
if (state.contracts[contractID] || state[contractID]) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/model/contracts/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ sbp('chelonia/defineContract', {
const rootState = sbp('state/vuex/state')
const username = data.username || meta.username
if (username === rootState.loggedIn.username) {
if (!sbp('okTurtles.data/get', 'JOINING_GROUP-' + contractID) || sbp('okTurtles.data/get', 'JOINING_GROUP_CHAT')) {
if (!sbp('okTurtles.data/get', 'JOINING_GROUP-' + contractID)) {
// while users are joining chatroom, they don't need to leave chatrooms
// this is similar to setting 'JOINING_GROUP' before joining group
await sbp('chelonia/contract/sync', data.chatRoomID)
Expand Down
2 changes: 1 addition & 1 deletion frontend/model/contracts/manifests.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifests": {
"gi.contracts/chatroom": "21XWnNGb27BabxLKJcHvKPjxLbzETfrcthDshd5GRsrpTXvY54",
"gi.contracts/group": "21XWnNNBbhSoianhSffVBT45mEsobrrcH7Pp2JuBVjwcuc3FDt",
"gi.contracts/group": "21XWnNMqySCEPHf7LFgpX44PgqVcffoE2UPy5g8MBjoZzo9STX",
"gi.contracts/identity": "21XWnNSxNrVFTMBCUVcZV3CG833gTbJ9V8ZyX7Fxgmpj9rNy4r"
}
}