private bool NeedsUploadReal(StandardFileTagRef tagref, IRemoteStorageSyncPersistance idata)
        {
            var data = (StandardNoteData)idata;

            if (tagref.UUID == null)
            {
                return(true);                                 // contains not-linked tagref
            }
            if (!data.Tags.Any(p => p.UUID == tagref.UUID))
            {
                return(true);                                                        // contains tagref that references missing tag
            }
            return(false);
        }
Exemple #2
0
 public void RemoveTag(StandardFileTagRef newtag)
 {
     _internalTags.Remove(newtag);
     ResyncTags();
 }
Exemple #3
0
 public void AddTag(StandardFileTagRef newtag)
 {
     _internalTags.Add(newtag);
     ResyncTags();
 }
Exemple #4
0
        public void UpgradeTag(StandardFileTagRef told, StandardFileTagRef tnew)
        {
            int idx = _internalTags.IndexOf(told);

            _internalTags[idx] = tnew;
        }
        private static void PrepareNoteForUpload(ISimpleJsonRest web, APIBodySync body, ref List <APIRawBodyItem> bodyraw, StandardFileNote note, List <StandardFileTag> allTags, APIResultAuthorize token, StandardNoteConfig cfg, bool delete)
        {
            var appdata = new Dictionary <string, Dictionary <string, object> >();

            SetAppDataBool(appdata, APPDATA_PINNED, note.IsPinned);
            SetAppDataBool(appdata, APPDATA_LOCKED, note.IsLocked);

            var objContent = new ContentNote
            {
                title      = note.InternalTitle,
                text       = note.Text.Replace("\r\n", "\n"),
                references = new List <APIResultContentRef>(),
                appData    = appdata,
            };

            // Set correct tag UUID if tag already exists
            foreach (var itertag in note.InternalTags.ToList())
            {
                var itag = itertag;

                if (itag.UUID == null)
                {
                    var newTag = allTags.FirstOrDefault(e => e.Title == itag.Title)?.ToRef();
                    if (newTag == null)
                    {
                        newTag = new StandardFileTagRef(Guid.NewGuid(), itag.Title);
                        allTags.Add(new StandardFileTag(newTag.UUID, newTag.Title, Enumerable.Repeat(note.ID, 1)));
                    }

                    note.UpgradeTag(itag, newTag);
                }
            }

            // Notes no longer have references to their tags (see issue #88)
            //foreach (var itertag in note.InternalTags.ToList())
            //{
            //	Debug.Assert(itertag.UUID != null, "itertag.UUID != null");
            //	jsnContent.references.Add(new APIResultContentRef { content_type = "Tag", uuid = itertag.UUID.Value });
            //}

            var jsonContent = web.SerializeJson(objContent);

            var cryptData = StandardNoteCrypt.EncryptContent(token.version, jsonContent, note.ID, token.masterkey, token.masterauthkey);

            body.items.Add(new APIBodyItem
            {
                content_type = "Note",
                uuid         = note.ID,
                created_at   = note.CreationDate,
                enc_item_key = cryptData.enc_item_key,
                auth_hash    = cryptData.auth_hash,
                content      = cryptData.enc_content,
                deleted      = delete,
            });
            bodyraw.Add(new APIRawBodyItem
            {
                content_type = "Note",
                uuid         = note.ID,
                created_at   = note.CreationDate,
                content      = jsonContent,
                deleted      = delete,
            });
        }